问题描述
我正在尝试使用PHP来exec()
二进制casperjs
I'm trying to use PHP to exec()
a binary casperjs
,
exec('casperjs /var/www/mysite/application/phantomjs/test.js');
但是我遇到了错误
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
CasperJS在PhantomJS之上运行,我都手动安装并在/usr/local/bin/phantomjs
和/usr/local/bin/casperjs
上创建了一个链接.因此,我猜测casperjs在运行时会调用phantomjs.
CasperJS runs on top of PhantomJS, both which I manually installed and created a link at /usr/local/bin/phantomjs
and /usr/local/bin/casperjs
. So I am guessing casperjs calls phantomjs when it runs.
但是,当我SSH进入服务器并运行时,它工作正常
However it works fine when I ssh into the server and run
casperjs /var/www/mysite/application/phantomjs/test.js
出了什么问题?我认为casperjs
无法以网络用户身份运行phantomjs
吗?如果是这样,如何解决?
What went wrong? I think casperjs
cannot run phantomjs
as a web user? If this is true, how can it be fixed?
推荐答案
只需尝试使用程序的完整路径调用exec
命令.例如
Just try to call the exec
command with the full path of the program. For example
exec('/usr/local/bin/casperjs /var/www/mysite/application/phantomjs/test.js');
还要确保您被允许通过Web服务器执行该程序,尤其是如果您使用php safe_mode on
.看看 safe_mode_exec_dir
Also make sure that you are allowed to execute that program via the web server, especially if you use the php safe_mode on
. Have a look at safe_mode_exec_dir
这篇关于使用PHP的exec()会产生错误:致命:[Errno 2]没有这样的文件或目录;你安装了吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!