PhantomJS PHP exec()命令在浏览器中不起作用

PhantomJS PHP exec()命令在浏览器中不起作用,php,permissions,phantomjs,Php,Permissions,Phantomjs,我使用phantom JS获取网页的原始HTML。 当我使用终端时,它工作,但在浏览器中不工作。 请参阅以下照片: exec("/Users/kaustubh/Desktop/phantomjs /Users/kaustubh/Desktop/loadspeed.js "."http://www.google.com ",$output); var_dump($output); 我已经提到了许多类似的问题,结论是与许可有关。 你对这个错误怎么看? loadspeed.js的代码是: var p

我使用phantom JS获取网页的原始HTML。 当我使用终端时,它工作,但在浏览器中不工作。 请参阅以下照片:

exec("/Users/kaustubh/Desktop/phantomjs /Users/kaustubh/Desktop/loadspeed.js "."http://www.google.com ",$output);
var_dump($output);
我已经提到了许多类似的问题,结论是与许可有关。

你对这个错误怎么看? loadspeed.js的代码是:

var page = require('webpage').create(),system = require('system'),t, address;
 if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit(1);
}else{
address=system.args[1];
var websiteAddress = address;
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 
Safari/537.36';
page.viewportSize = { width: 1920, height: 1080 };

 page.clipRect = { top: 0, left: 0, width: 1920, height: 1080 }; page.open(websiteAddress, function (status) {
    setTimeout(function(){
    page.render('github.png');
    console.log(returnChunksArray(page.content,6000));
    phantom.exit();
 }, 5000); // 5 sec should be enough
});
}
function returnChunksArray(str, chunkSize) {
 var arr = [];
 while(str !== '') {
    arr.push(str.slice(0, chunkSize));
    str = str.slice(chunkSize);
 }
 return arr;
}
var page=require('webpage')。create(),system=require('system'),t,address;
if(system.args.length==1){
log('用法:loadspeed.js');
幻影。出口(1);
}否则{
地址=system.args[1];
var websiteAddress=地址;
page.settings.userAgent='Mozilla/5.0(Windows NT 10.0;Win64;x64)
AppleWebKit/537.36(KHTML,比如Gecko)Chrome/60.0.3112.113
Safari/537.36';
page.viewportSize={宽度:1920,高度:1080};
page.clipRect={top:0,left:0,width:1920,height:1080};page.open(网站地址,函数(状态){
setTimeout(函数(){
page.render('github.png');
日志(returnChunksArray(page.content,6000));
phantom.exit();
},5000);//5秒应该足够了
});
}
函数returnChunksArray(str,chunkSize){
var-arr=[];
while(str!=''){
arr.push(str.slice(0,chunkSize));
str=str.slice(chunkSize);
}
返回arr;
}
当涉及到浏览器时:浏览器甚至不等待exec()函数。我甚至尝试了shell\u exec(),但没有成功。

hpantomjs的权限为读写:

但在终端中,它按预期加载。
谢谢

你甚至可以通过PHP用
ls
这样的命令运行一个最简单的
shell\u exec
吗?我想我已经解决了。这是权限问题。只需将phatomjs目录和loadspeed.js更改为服务器目录。感谢您的回复