(这里有一些在线提及,但没有解决scheme。)我想能够使用PHP脚本中的shell_exec和exec。
含义,使用:
<? exec("echo hello world"); ?>
要么
<? shell_exec("echo hello world"); ?>
根据我在网上find的链接( http://forums.cpanel.net/f5/enable-shell_exec-one-user-109601.html ),一种方法是在VirtualHost下添加指令:
<IfModule mod_php5.c> php_admin_value suhosin.executor.func.blacklist = “shell_exec” </IfModule>
但是当我看着configuration文件,试图重新启动networking服务器,我得到:
28/07/14 17:18:26: Syntax error on line 1 of /etc/httpd/conf.d/serv1.conf: 28/07/14 17:18:26: php_admin_value takes two arguments, PHP Value Modifier (Admin)
并且服务器没有重新启动。
任何想法如何启用exec和shell_exec? 我无法追查这个错误的来源。
编辑:我不是在机器上的根。 我找不到一个php.ini文件,但有一个/etc/httpd/conf.d/php.conf文件,它没有disable_functions。
这里是:
# # PHP is an HTML-embedded scripting language which attempts to make it # easy for developers to write dynamically generated webpages. # <IfModule prefork.c> LoadModule php5_module modules/libphp5.so </IfModule> <IfModule worker.c> LoadModule php5_module modules/libphp5-zts.so </IfModule> # # Cause the PHP interpreter to handle files with a .php extension. # AddHandler php5-script .php AddType text/html .php # # Add index.php to the list of files that will be served as directory # indexes. # DirectoryIndex index.php # # Uncomment the following line to allow PHP to pretty-print .phps # files as PHP source code: # #AddType application/x-httpd-php-source .phps
如果你不是机器上的根,并且exec()
函数被禁用,那么你不能自己启用它。
请参阅http://php.net/manual/en/ini.core.php#ini.disable-functions
disable_functions字符串
此指令允许您出于安全原因禁用某些功能。 它使用逗号分隔的函数名称列表。 disable_functions不受安全模式的影响。
只有内部函数可以使用这个指令禁用。 用户定义的功能不受影响。
这个指令必须在php.ini中设置。例如,你不能在httpd.conf中设置这个指令 。
您需要通过浏览\Apache2\bin
(不是文件夹)来禁用PHP中的安全模式,然后重新启动服务器。
点击这里和这里 。
从功能中删除
disable_functions=""
在你的php.ini文件中
或者如果你有Suhosin,那么在suhosin.executor.func.blacklist下检查Suhosin配置文件中的设置
由于php_admin_value需要两个参数,不需要=
符号,所以使用
php_admin_value suhosin.executor.func.blacklist "shell_exec"
或者阻止多个php函数的使用
php_admin_value suhosin.executor.func.blacklist "shell_exec, opendir, file_get_contents, phpinfo"