php 在主机上启用 system() 和 exec() 函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13980404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable system() and exec() functions on hosting?
提问by Elijah Murray
I'm a developer and I build client sites on my server and then use a PHP script to clone it to the client's server when finished. I tried this time but am getting an error of
我是一名开发人员,我在我的服务器上构建客户端站点,然后在完成后使用 PHP 脚本将其克隆到客户端的服务器。这次我试过了,但出现错误
"Your host does not allow the use of the system() and exec() functions."
“您的主机不允许使用 system() 和 exec() 函数。”
Any idea how to enable this? I have cpanel access and the host account is greengecko.com. Installing Wordpress was easy, I just can't run this script!
知道如何启用此功能吗?我有 cpanel 访问权限,主机帐户是 greengecko.com。安装 Wordpress 很简单,我就是不能运行这个脚本!
回答by Drekryan
If your host disabled these functions there will be no way to enable them. You can either consider contacting your host to see if they would enable them for a per account basis or if you are using Free hosting you may consider upgrading to a paid version of their hosting for those functions to be enabled. They are disabled by the host for security reasons. Your only course of action however if to contact your web host or try upgrading to paid hosting(if not already).
如果您的主机禁用了这些功能,则将无法启用它们。您可以考虑联系您的主机,看看他们是否会为每个帐户启用它们,或者如果您使用的是免费主机,您可以考虑升级到他们主机的付费版本以启用这些功能。出于安全原因,它们被主机禁用。但是,您唯一的做法是联系您的网络主机或尝试升级到付费主机(如果还没有)。
回答by plasmid87
Some hosting providers enable the ability to override php.inisettings from within .htaccess (if Apache Httpd) or using a separate php.ini file from somewhere within the hosting account directory.
某些托管服务提供商能够从 .htaccess(如果是 Apache Httpd)或使用托管帐户目录中某处的单独 php.ini 文件覆盖php.ini设置。
I am not familiar with your hosting provider and so cannot comment on whether this will be possible. However, I can say that if you are able to take advantage of such a facility, you are probably looking for the disable_functionsdirective.
我不熟悉您的托管服务提供商,因此无法评论这是否可行。但是,我可以说,如果您能够利用这样的功能,那么您可能正在寻找disable_functions指令。
As a further piece of advice, if you find yourself able to "re-enable" protected PHP functions and this is on a client's account, I cannot stress enough how important it is you remember to "re-disable" them again afterwards (disabling exec()and system()on hosting accounts is increasingly becoming a necessity as exploits and simple mistakes are extremely costly to server security).
作为进一步的建议,如果您发现自己能够“重新启用”受保护的 PHP 功能并且这是在客户的帐户上,那么我再怎么强调您记住之后再次“重新禁用”它们(禁用exec()并且system()在托管帐户上越来越成为一种必需品,因为漏洞利用和简单的错误对服务器安全的成本非常高)。
回答by Mario Bruneau
Elijah, I too had the very same problem about the system() and exec() NOT inabled in php.
Elijah,我也有关于 system() 和 exec() 在 php 中没有禁用的问题。
Just download the php.ini file that is in the root of your website via FTP and you'll find something like this:
只需通过 FTP 下载位于您网站根目录中的 php.ini 文件,您就会发现如下内容:
register_globals = On
safe_mode = Off
enable_dl = On
disable_functions = "exec,passthru,shell_exec,proc_open,popen,system,curl_exec,curl_multi_exec,parse_ini_file,show_source"
Just remove exec,(the first word in the line between "") that is on the disable_functions line and also remove system,
只需删除disable_functions行上的exec,(“”之间的行中的第一个单词)并删除系统,
Don't forget to remove the comas (,) with the two words.
不要忘记删除两个单词的逗号 (,)。
It worked for me.
它对我有用。
Mind you, I had created this php.ini file myself about a month ago but I don't know why, by changing the php version in cPanel, the exec and system came back.
请注意,我大约一个月前自己创建了这个 php.ini 文件,但我不知道为什么,通过更改 cPanel 中的 php 版本,exec 和系统又回来了。
Follow also the good advice given here by plasmid87 to putt it back on when finish with creating the clone of your site.
在完成创建您的站点的克隆后,请遵循质粒 87 在此处给出的好建议,以将其放回原处。
Mario Bruneau
马里奥布鲁诺

![php $_SERVER['HTTP_REFERER'] 的结果,当引用标头未发送到服务器时](/res/img/loading.gif)