Have you ever spent a ridiculous amount of time on a problem while knowing that you alone must be doing something wrong because of the lack of anyone else having your issue anywhere on the interwebs?
I think this falls into that category.
Problem: I am trying to execute an external call to phantomjs from a php script. When the command or the php script are ran from the command line, it works like a newly oiled engine. When the php script is called from a browser, phantomjs crashes.
I have downloaded both the 32-bit and 64-bit latest versions (1.8.2) to verify it was not simply a problem with either on the DH server.
The test command is:
“2>&1” is appended to the end when called from the php script to display errors.
The PHP test script is simply:
$cmd = “/home/myusername/my.com/manual/phantomjs /home/myusername/my.com/manual/hello.js 2>&1”;
- When the test command is called directly from the command line, it works perfectly.
- When the php script is called from the command line (php php.test), it works perfectly.
- When the php script is navigated to from the browser, I get:
Intriguing facet: If the command for simply requesting the version number is called (phantomjs -v), all three types of calls work.
I have tried the following in attempting to figure out the cause:
- Redownloaded the binaries
- Set the permissions to 777 for all files and directories involved.
- Used both relative and absolute paths.
- Verified through exec(“whoiam”) that it is indeed using my primary user.
- Turned off Extra Web Security and FastCGI
- Sacrificed to multiple deities.
This fine young person had a different problem when trying to do the same, but it’s worth noting: https://discussion.dreamhost.com/thread-137268.html?highlight=phantomjs
I would be happy, or even quite ecstatic, if you could offer any help about what I am clearly, and probably foolishly, doing wrong. Thanks!