Reputation: 588
I;m trying to run phantomjs from php. To check correct path and permissions, as first I execute this commands:
$output = shell_exec('ls /opt/phantomjs-1.9.2-linux-x86_64/bin/ -l');
echo "<pre>$output</pre>";
Result:
-rwxrwxrwx. 1 root root 38526976 Sep 7 11:17 phantomjs
drwxrwxrwx. 2 root root 4096 Feb 10 15:44 savedpages
-rwxrwxrwx. 1 root root 803 Jan 19 18:36 saveonepagelin.js
-rwxrwxrwx. 1 root root 4074 Jan 19 19:00 test.js
But when I run:
$output = shell_exec('/opt/phantomjs-1.9.2-linux-x86_64/bin/phantomjs --version');
echo "<pre>$output</pre>";
Output is empty :( why? Thanks!
Upvotes: 0
Views: 1991
Reputation: 143
I got the same error, and I try to modify the dir where I execute the phantomjs and set the mode with 777, then it worked. I guess the root cause if the owner of the php-fpm doesn't have right to write image into the dir.
my code for refer:
$output = passthru('phantomjs echarts-convert.js -options ' . $options . ' -outfile line.png');
echo $output;
Upvotes: 0
Reputation: 258
My first guess would be a permission problem. Is the www-data user (or whichever user your server is called) allowed to run the program?
Do you get anything returned if you place $output in var_dump() instead? I.e.
$output = shell_exec('/opt/phantomjs-1.9.2-linux-x86_64/bin/phantomjs --version');
var_dump($output);
Upvotes: 1