如何在php上启用shell_exec和exec?

klo*_*oop 6 php apache web

(在网上有一些提及,但没有一个解决方案有效.)我希望能够从PHP脚本中使用shell_exec和exec.

含义,使用:

<? exec("echo hello world"); ?> 
Run Code Online (Sandbox Code Playgroud)

要么

<? shell_exec("echo hello world"); ?>
Run Code Online (Sandbox Code Playgroud)

根据我在网上找到的链接(http://forums.cpanel.net/f5/enable-shell_exec-one-user-109601.html),一种方法是在VirtualHost下添加指令:

php_admin_value suhosin.executor.func.blacklist ="了shell_exec"

但当我查看配置文件,尝试重新启动网络服务器时,我得到:

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)
Run Code Online (Sandbox Code Playgroud)

并且服务器未重新启动.

任何想法如何启用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
Run Code Online (Sandbox Code Playgroud)

Ada*_*dam 10

如果您不是计算机上的根,并且exec()功能已禁用,则您无法自行启用它.

请参见http://php.net/manual/en/ini.core.php#ini.disable-functions

disable_functions字符串

该指令允许您出于安全原因禁用某些功能.它采用以逗号分隔的函数名列表.disable_functions不受安全模式的影响.

使用此指令只能禁用内部函数.用户定义的函数不受影响.

必须在php.ini中设置此指令.例如,您无法在httpd.conf中设置此指令.


Avi*_*abu 1

您需要通过浏览\Apache2\bin(不是文件夹)并重新启动服务器来禁用 PHP 中的安全模式。

检查这里这里