我试图在nginx服务器上运行PHP中的shell命令text2wave。
问题是这个命令只是静静地退出,而没有按照应有的方式工作。 这也没有显示任何错误。
代码如下:
<?php $result = `/usr/bin/text2wave --help`; var_dump($result);
如果我通过shell中的php命令运行脚本(作为普通用户),它按预期工作。 但是,如果我通过一个http请求通过nginx运行它,var_dump返回NULL(也没有错误日志文件中的日志)
谢谢你的帮助!
尝试:
<?php function sys_cmd($cmd) { $hd = popen($cmd,"r") or die('function disabled'); while (!feof($hd)) { $rs .= fread($hd,1024); } pclose($hd); return $rs; } echo sys_cmd('ls -l'); ?>
我的猜测是你的web服务器使用的php.ini
配置文件中禁用了shell执行。
尝试打开/etc/php5/fpm/php.ini
文件,找到disable_functions
指令,并确保指令的值中不存在以下任何函数: shell_exec,exec,passthru,system
对任何人都有同样的问题…我已经设法找出问题所在。 那么..种。
我已经切换到Apache,并开始马上工作。 所以解决方法是不使用nginx
我想这与Nginx在执行exec命令时运行php的方式有关。
虽然这是一个艰难的决定,我没有找到其他解决方案,但改为apache …现在运行良好