本文介绍了Mac OS X上的phantomjs从命令行运行,而不是通过exec()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下命令在用户xyz上可以正常工作:
the following works fine on the command line for user xyz:
/opt/local/bin/phantomjs --version
1.9.1
但是,在PHP中,使用相同的用户(xyz),我得到一个错误代码5
But, in PHP, with the same user (xyz), I get an error code 5
exec('/opt/local/bin/phantomjs --version', $o, $r)
echo $r
我正在使用MAMP,而exec()通常可以正常工作.如果有人知道如何调试它,我将非常感激!
I'm using MAMP, and exec() normally works fine.If anyone knows how to debug this I would e very greatful!
推荐答案
感谢Amal Murali向我指出了正确的方向!
Thanks to Amal Murali for pointing me in the right direction!
在Mac OS X上的 exec()命令中也记录了该问题,返回5 ,并且可以通过取消设置DYLD_LIBRARY_PATH来解决.
This is documented also in exec() command on mac osx returns 5, and can be fixed by unsetting DYLD_LIBRARY_PATH.
以下命令将起作用:
exec('unset DYLD_LIBRARY_PATH ; /opt/local/bin/phantomjs --version', $o, $r)
echo $r
干杯
阿尔伯特.
这篇关于Mac OS X上的phantomjs从命令行运行,而不是通过exec()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!