2013-05-28 10 views
0

我正在尝试使用shell_exec命令从另一个PHP脚本调用PHP脚本。当我使用相同的用户在shell中输入相同的命令时,所有内容都按预期工作。然而,当我把它在PHP中我得到了以下的输出:exec无法找到要执行的PHP文件

X-Powered-By: PHP/5.3.23 
Content-type: text/html 

我的PHP调用是:

shell_exec('php -f /home/site/public_html/script.php > /home/site/log.txt &'); 

我检查服务器配置。安全模式关闭。 shell_exec('whoami')正在工作没有任何问题。

+3

也许'php'程序不可用或不在'$ PATH'中。尝试指定'php'二进制文件的完整路径。 – Havenard

+0

我试过shell_exec('/ usr/bin/php -f /home/site/public_html/script.php> /home/websity/log.txt &');和我得到了相同的输出,也从输出似乎PHP执行但找不到文件script.php – user2429783

+0

'/ usr/bin/php'存在吗? – Havenard

回答

1

尝试

shell_exec('/usr/bin/php -f /home/site/public_html/script.php > /home/site/log.txt &'); 

或键入

whereis php 

,并使用给定的路径。

+0

是的,我会从这里开始。 – dudewad

+0

我试过shell_exec('/ usr/bin/php -f /home/site/public_html/script.php> /home/websity/log.txt &');和我得到了相同的输出,也从输出看来,PHP执行,但无法找到该文件script.php – user2429783

+0

你可以给出输出吗?你也可以“ls -l /home/site/public_html/script.php”来确保它存在。 – beiller

相关问题