Cannot use shell_exec to run phantomjs in PHP - fine using goDaddy

I’ve recently moved from goDaddy hosting to Dreamhost.

I could previously run phantomjs ( using a shell_exec command in PHP, however I am no longer able to using Dreamhost hosting.

On goDaddy I was able to download, extract & run the Linux version of phantomjs (phantomjs-1.8.1-linux-x86_64.tar.bz2) from I copied the resulting file structure to my hosting account where I could run phantomjs using the PHP code, e.g.

shell_exec("/home/username/phantomjs/bin/phantomjs /home/username/phantomjs/examples/rasterize.js ‘’ test.pdf ‘A4’);

This uses the inbuilt rasterize script to output a PDF from a URL.

On Dreamhost no derivation I’ve tried of the above works, and when attempting to run via the shell I get a -bash permission denied.

I really need to be able to run using shell_exec and have looked everywhere but to no avail. Any help would be much appreciated!

The error should be just a tad more verbose than that.

Check that the file is executable.

The error is:

-bash: /home/username/phantomjs/bin/phantomjs: permission denied

Thats about as verbose as it gets Im afraid.

The result of a file call is:

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

That sounds like you downloaded the 32-bit version of phantomjs, not the 64-bit version. Download the right one and try again? (Worked for me when I tried it.)

Afraid not- I was using the 64 bit version (phantomjs-1.8.1-linux-x86_64.tar.bz2)

The results you’re showing from running “file” differ from what I got, and suggest very strongly that it’s the 32-bit version. (In particular, the “ELF 32-bit LSB executable” bit.) Can you please try redownloading the 64-bit version? If that doesn’t work, email me with your shell username and I’ll take a look.