【问题标题】:php execution phantom js works but casperjs does not work permission deniedphp执行幻影js工作但casperjs不工作权限被拒绝
【发布时间】:2014-02-04 21:17:43
【问题描述】:

好的,所以我正在运行带有 zpanel 设置的 centos 6.5。 然后这有 phantom js 和 casperjs 都设置和工作了

/usr/local/bin 

目录。

我将这个 php 命令用于 phantomjs 和 casperjs

 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

【问题讨论】:

  • 必须有人来帮助我尝试更改权限,由于没有 tty,我无法使用 sudo
  • 文件的权限是什么,试试chmod a+x casperjs
  • 我已经尝试过了,但它仍然失败,不幸的是我不知道权限我忘记了命令我从大学回家时会看看
  • 我在上面的线程@BriceFavre 中添加了输出
  • 您可以尝试更改目标的权限 - /root/casperjs/bin/casperjs。符号链接不受chmod 的影响。参考:superuser.com/questions/303040/…

标签: javascript php phantomjs casperjs


【解决方案1】:

我自己回答的另一个问题我很高兴我开始了解这个新爱好:) 无论如何,幸运的是,我在根据需要开发服务器时以及每次完成任务时都在使用虚拟机 像安装 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

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

【讨论】:

  • 谢谢!!putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");是必须的。
  • Permission denied的原因是你在/root中安装了casperjs
猜你喜欢
  • 1970-01-01
  • 2014-07-11
  • 2016-02-27
  • 1970-01-01
  • 2020-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多