javascript - php 执行 phantom js 可以工作,但 casperjs 不工作 权限被拒绝

标签 javascript php phantomjs casperjs

好吧,我正在运行带有 zpanel 设置的 centos 6.5。 然后 phantom js 和 casperjs 都已设置并运行

/usr/local/bin 

目录。

我对 phantomjs 和 casperjs 使用这个 php 命令

 echo exec('/usr/local/bin/casperjs --version 2>&1');

phantomjs 工作正常,但 casperjs 给了我这个错误

sh: /usr/local/bin/casperjs: Permission denied

谁能帮我解决这个问题,这真是一个痛苦

output for ls -al casperjs


   [root@cyber-hosted ~]# ls -al casperjs
total 100
 drwxr-xr-x  10 apache root 4096 Feb  4 15:49 .
dr-xr-x---.  5 root   root 4096 Feb  4 15:49 ..
drwxr-xr-x   2 root   root 4096 Feb  4 15:49 bin
-rw-r--r--   1 root   root 1220 Feb  4 15:49 casperjs.gemspec
-rw-r--r--   1 root   root   75 Feb  4 15:49 CHANGELOG.md
-rw-r--r--   1 root   root 4929 Feb  4 15:49 CONTRIBUTING.md
-rw-r--r--   1 root   root 1524 Feb  4 15:49 CONTRIBUTORS.md
drwxr-xr-x   6 root   root 4096 Feb  4 15:49 docs
drwxr-xr-x   8 root   root 4096 Feb  4 15:49 .git
-rw-r--r--   1 root   root   12 Feb  4 15:49 .gitattributes
-rw-r--r--   1 root   root   71 Feb  4 15:49 .gitignore
 -rw-r--r--   1 root   root    0 Feb  4 15:49 .gitmodules
 -rw-r--r--   1 root   root  145 Feb  4 15:49 .jshintignore
 -rw-r--r--   1 root   root  528 Feb  4 15:49 .jshintrc
 -rw-r--r--   1 root   root 1066 Feb  4 15:49 LICENSE.md
 -rw-r--r--   1 root   root  552 Feb  4 15:49 Makefile
 drwxr-xr-x   2 root   root 4096 Feb  4 15:49 modules
 -rw-r--r--   1 root   root  767 Feb  4 15:49 package.json
 -rw-r--r--   1 root   root 4558 Feb  4 15:49 README.md
 drwxr-xr-x   2 root   root 4096 Feb  4 15:49 rpm
 drwxr-xr-x   2 root   root 4096 Feb  4 15:49 samples
 drwxr-xr-x   2 root   root 4096 Feb  4 15:49 src
 drwxr-xr-x   7 root   root 4096 Feb  4 15:49 tests
-rw-r--r--   1 root   root 3093 Feb  4 15:49 .travis.yml

ls -al/usr/local/bin 的输出(我在 php 中执行的位置)

total 37744
drwxr-xr-x.  2 root root     4096 Feb  4 22:08 .
drwxr-xr-x. 11 root root     4096 Feb  2 00:49 ..
lrwxrwxrwx   1 root root       27 Feb  4 22:08 casperjs -> /root/casperjs/bin/ca                         sperjs
-rwxr-xr-x   1 root root 38641084 Feb  4 15:48 phantomjs

最佳答案

我自己回答的另一个问题我很高兴我开始了解这个新爱好:) 无论如何,幸运的是,我在根据我的需求开发服务器时以及每次完成任务时都使用虚拟盒 就像安装 Zpanel 配置它一样,我创建了一个克隆。

所以我所做的就是恢复到 PhantomJS 和 CasperJS 之前设置的服务器。 然后我使用以下方法安装了 PhantomJS 和 CasperJS,然后使用我的 test.php 脚本进行测试 服务器功能

好吧,我使用以下命令来安装 PhantomJS

# wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-i686.tar.bz2
# tar xvf phantomjs-1.9.1-linux-i686.tar.bz2
# cp phantomjs-1.9.1-linux-i686/bin/phantomjs /usr/local/bin

然后我使用这些命令来安装 CasperJS

# cd /opt
# wget https://codeload.github.com/n1k0/casperjs/legacy.zip/1.1-beta3
# unzip 1.1-beta3
# ln -s n1k0-casperjs-4f105a9/ casperjs
# ln -s /opt/casperjs/bin/casperjs /usr/local/bin/

然后我在我的服务器上创建了这个

PHP测试文件Test.php

<?php
    ## This Function Below Sets PhantomJs So CasperJS Can Use It
    putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
    echo "Running PhantomJS version: ";
    echo exec('/usr/local/bin/phantomjs --version 2>&1');
    echo "<br />";
    echo "Running CasperJS version: ";
    echo exec('/usr/local/bin/casperjs --version 2>&1');

?>

之后我运行了 Test.php 并得到了这个结果

Running PhantomJS version: 1.9.7
Running CasperJS version: 1.1.0-beta3

我的服务器现在使用 PhantomJS 运行 CasperJs

如果您喜欢这个答案,请升级:)

关于javascript - php 执行 phantom js 可以工作,但 casperjs 不工作 权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21563640/

相关文章:

php - 声明php数组为javascript数组的情况

php - 如何在 Twenty Twelve WordPress 主题中设置固定标题?

javascript - 如何使 jssor 字幕仅出现在鼠标悬停时?

javascript - 如何在 Jest 测试中为无状态函数的输入文本元素设置值

php - 在 Silex 中使用 Symfony Form 2.3

node.js - 在 MeteorJS 中使用 PhantomJS 时找不到模块 'webpage'

asynchronous - 脚本错误(:0) when trying to run async test in mocha-phantomjs

npm - phantomjs:如何在 phantomjs 中使用 npm 模块?

javascript - 如何在javascript中呈现数据?

javascript - JQuery - 每里编号