问题描述
(网上有一些提及,但没有一个解决方案有效.)我希望能够从 PHP 脚本中使用 shell_exec 和 exec.
含义,使用:
或
根据我在网上找到的链接(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:/etc/httpd/conf.d/serv1.conf 第 1 行的语法错误:28/07/14 17:18:26:php_admin_value 有两个参数,PHP 值修饰符(管理员)
并且服务器没有重新启动.
任何想法如何启用 exec 和 shell_exec?我无法追踪此错误的来源.
我不是机器上的根.我找不到 php.ini 文件,但有一个/etc/httpd/conf.d/php.conf 文件并且它没有 disable_functions.
这是:
## PHP 是一种嵌入 HTML 的脚本语言,它试图让它# 便于开发者编写动态生成的网页.#<IfModule prefork.c>LoadModule php5_module modules/libphp5.so</IfModule><IfModule worker.c>LoadModule php5_module modules/libphp5-zts.so</IfModule>## 使 PHP 解释器处理扩展名为 .php 的文件.#AddHandler php5-script .php添加类型文本/html .php## 将 index.php 添加到将用作目录的文件列表中# 索引.#目录索引 index.php## 取消注释以下行以允许 PHP 漂亮地打印 .phps# 文件作为 PHP 源代码:##AddType application/x-httpd-php-source .phps如果你不是机器上的root,并且exec()
函数被禁用了,那你就不能自己启用.
参见http://php.net/manual/en/ini.core.php#ini.disable-functions
disable_functions 字符串
该指令允许您出于安全原因禁用某些功能.它采用逗号分隔的函数名称列表.disable_functions 不受安全模式的影响.
使用该指令只能禁用内部函数.用户定义的函数不受影响.
这个指令必须在php.ini中设置 例如,你不能在httpd.conf中设置.
(There is some mention of this online, but none of the solutions worked.)I want to be able to use shell_exec and exec from a PHP script.
Meaning, use:
<? exec("echo hello world"); ?>
or
<? shell_exec("echo hello world"); ?>
According to a link I found online (http://forums.cpanel.net/f5/enable-shell_exec-one-user-109601.html), one way to do it is to add under VirtualHost the directives:
php_admin_value suhosin.executor.func.blacklist = "shell_exec"but when I looked at the configuration file, trying to restart the webserver, I get:
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)
and the server is not restarted.
Any ideas how to enable exec and shell_exec? I can't trace the origin of this error.
EDIT: I am not the root on the machine. I couldn't find an php.ini file, but there is an /etc/httpd/conf.d/php.conf file and it has no disable_functions.
Here it is:
#
# 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
If you are not the root on the machine, and exec()
function is disabled, then you can't enable it by yourself.
See http://php.net/manual/en/ini.core.php#ini.disable-functions
这篇关于如何在php上启用shell_exec和exec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!