Ethan
Ethan

Reputation: 2087

How to Run PhantomJS Hostgator via PHP Shell Script

I am trying to run PhantomJS on my server hosted by HostGator. Phantom is initiated by a shell script that:

  1. Initializes Phantom JS and passes in the script to execute and
  2. Passes in three variables.

This code has worked perfectly fine on my Xampp Server, but began giving me trouble as soon as I uploaded the entire project to hostgator. I have been able to verify that, up until this script is called, everything operates the way it was designed to. Here is the script that initializes PhantomJS:

<?php  
$URL = $_POST['url'];
$USER = $_POST['user'];
$PASSWORD = $_POST['password'];

$res = shell_exec("...EXACT PATH/scripts/phantom/bin/phantomjs ...EXACT PATH/scripts/phantom/examples/test.js 2>&1 $URL $USER $PASSWORD");
echo json_encode(preg_replace("/[^A-Za-z]/", '', $res));
?>

All of the variables are properly passed into this script. When called, the console prints the following (this is its raw form minus the path to the files)

xbxffdddliblibcsolibcstartmainxfdxffdddxaPhantomJShascrashedPleasereadthebugreportingguideathttpphantomjsorgbugreportinghtmlandfileabugreport

Or, with spaces added,

PhantomJS has crashed. Please read the bug reporting guide at http://phantomjs.org/bugreporting.html and file a bug report

I was told by Hostgator reps that the server itself is 64 bit, and I have made SURE to upload the correct version to the server. I have done some research on Hostgator servers, and have found the max timeout time for PHP scripts is 30 seconds--this throws the error usually within 2.

Any ideas as to why this is happening?

Upvotes: 0

Views: 290

Answers (0)

Related Questions