2013-10-07 24 views
3

我使用PHP共享庫時PHP的exec()被調用沒有被加載

$commstr = '/abs/path/to/binary > status.txt &'; 
echo "Running command: ".$commstr."\n"; 
shell_exec($commstr); 

PHP exec()或與此有關,因爲status.txt中被寫入system()shell_exec()工作正常觸發可執行文件,但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

我想 - 因爲它不是以絕對路徑的工作 - PHP有沒有關係 - 它的外部二進制 –

+0

裏面有問題嘛,我可以運行命令行 –

+0

二進制因此,嘗試'cd('/ path/to/bin');'在你的PHP腳本中 –

回答

0

嘗試像sudo一樣運行該命令。

例如

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

不,這會導致相同的錯誤。理想情況下,用戶apache不應該是sudoers的一部分。 –