我正在使用php触发可执行文件
$commstr = '/abs/path/to/binary > status.txt &';
echo "Running command: ".$commstr."'n";
shell_exec($commstr);
PHP exec()
或就此而言,system()
或shell_exec()
工作正常,因为状态.txt被写入,但cat status.txt
说error while loading shared libraries: libQtCore.so.4: cannot open shared object file: No such file or directory
。这意味着二进制文件不会被执行
我尝试将我的 php 代码更改为以下内容,但没有任何运气
$commstr = 'export LD_LIBRARY_PATH=/path/to/lib ; /abs/path/to/binary > status.txt &';
二进制文件可由用户apache
读取,库也是如此。
尝试以 sudo 身份运行该命令。
例如
$commstr = 'sudo export LD_LIBRARY_PATH=/path/to/lib ; /abs/path/to/binary > status.txt &';