问题
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
"Your host does not allow the use of the system() and exec() functions."
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!
回答1:
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).
回答2:
Some hosting providers enable the ability to override php.ini settings from within .htaccess (if Apache Httpd) or using a separate php.ini file from somewhere within the hosting account directory.
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_functions directive.
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).
回答3:
Elijah, I too had the very same problem about the system() and exec() NOT inabled in php.
Just download the php.ini file that is in the root of your website via FTP and you'll find something like this:
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,
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.
Follow also the good advice given here by plasmid87 to putt it back on when finish with creating the clone of your site.
Mario Bruneau
来源:https://stackoverflow.com/questions/13980404/enable-system-and-exec-functions-on-hosting