我正在尝试在 HostGator 托管的服务器上运行 PhantomJS。Phantom 由一个 shell 脚本启动,该脚本:
- 初始化 Phantom JS 并传入脚本执行和
- 传入三个变量。
这段代码在我的 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 秒内引发错误。
关于为什么会发生这种情况的任何想法?