从PHP调用bash脚本失败,但它在本地工作


Calling bash script from PHP fails, but it works locally

我正在使用PHP的shell_exec()调用bash脚本,并且我已经确定了它挂起的行:

我在那行使用WinExe,挂起的行是这样的(敏感值明显删除):

result=`${LOCATION}/bin/winexe -U "user%password" //gateway "g:''folder''myscript.bat $1 $2"`

如果我从终端调用这个脚本,它工作得很好,但如果我从PHP调用它,web服务器挂起,直到我使用

杀死进程才恢复正常:
fuser -k -n tcp 80

Solved via:

https://stackoverflow.com/a/6016750/270302

我基本上使用proc_open而不是shell_exec