簡體   English   中英

如何在php上啟用shell_exec和exec?

[英]how to enable shell_exec and exec on php?

(網上有人提到了這一點,但沒有一個解決方案有效。)我希望能夠從 PHP 腳本中使用 shell_exec 和 exec。

意思是,使用:

<? exec("echo hello world"); ?> 

或者

<? shell_exec("echo hello world"); ?>

根據我在網上找到的鏈接( 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)

並且服務器沒有重新啟動。

任何想法如何啟用 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

如果您不是機器上的root,並且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配置文件您的設置suhosin.executor.func.blacklist

由於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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM