调用php exec()时未加载共享库

时间:2013-10-07 13:31:14

标签: php shared-libraries

我使用php

触发可执行文件
$commstr = '/abs/path/to/binary > status.txt &';
echo "Running command: ".$commstr."\n";
shell_exec($commstr);

PHP exec()或者system()shell_exec()工作正常,因为status.txt被写入,但cat status.txterror 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读取,库也是如此。

1 个答案:

答案 0 :(得分:0)

尝试以sudo运行命令。

例如

$commstr = 'sudo export LD_LIBRARY_PATH=/path/to/lib ; /abs/path/to/binary > status.txt &';