如何通过PHP Shell脚本运行PhantomJS Hostgator

时间:2017-06-08 00:06:03

标签: php shell php-phantomjs

我正在尝试在HostGator托管的服务器上运行PhantomJS。 Phantom由以下shell脚本启动:

  1. 初始化Phantom JS并传入脚本执行和
  2. 通过三个变量。
  3. 这个代码在我的Xampp服务器上运行得非常好,但是一旦我将整个项目上传到hostgator就开始给我带来麻烦。我已经能够验证,在调用此脚本之前,所有内容都按其设计的方式运行。这是初始化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));
    ?>
    

    所有变量都正确传递到此脚本中。调用时,控制台将打印以下内容(这是原始格式减去文件的路径)

    xbxffdddliblibcsolibcstartmainxfdxffdddxaPhantomJShascrashedPleasereadthebugreportingguideathttpphantomjsorgbugreportinghtmlandfileabugreport
    

    或者,添加空格,

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

    Hostgator销售代表告诉我服务器本身是64 bit,我已经确保将正确的版本上传到服务器。我已经对Hostgator服务器做了一些研究,发现PHP脚本的最大超时时间是30秒 - 这通常会导致错误在2以内。

    有关为何发生这种情况的任何想法?

0 个答案:

没有答案