ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

javascript – php执行幻影js工作,但casperjs不工作权限被拒绝

2019-10-01 09:43:24  阅读:245  来源: 互联网

标签:javascript php phantomjs casperjs


好的,所以我用zpanel设置运行centos 6.5.
然后有幻影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

解决方法:

我自己回答的另一个问题我很高兴我开始明白这个新的爱好:)
幸运的是,我正在使用虚拟盒,同时根据我的需求开发我的服务器,每次我完成一项任务
像安装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,phantomjs,casperjs
来源: https://codeday.me/bug/20191001/1838470.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有