在共享主机(1and1)上安装PhantomJS

时间:2018-02-26 02:18:40

标签: php phantomjs composer-php shared-hosting php-phantomjs

使用1and1 linux共享主机,

我已安装:

PHP版本7.0.27 PHP PhantomJS 2.1.1

PHP PhantomJS所有值都为null

每当我提出请求时:

$client = Client::getInstance();

$client->getEngine()->setPath($main_path.'core/composer/bin/phantomjs');
$client->getEngine()->addOption('--ssl-protocol=any');
$client->getEngine()->addOption('--ignore-ssl-errors=true');
$client->getEngine()->addOption('--web-security=false');
$client->getEngine()->addOption('--debug=true');
$client->getEngine()->addOption('--local-to-remote-url-access=true');

$request = $client->getMessageFactory()->createRequest("http://luclaverdure.com");
$response = $client->getMessageFactory()->createResponse();

$client->send($request, $response);
var_dump($request);
var_dump($response);

if($response->getStatus() === 200) {
    $resp = $response->getContent();
    var_dump($resp);
}

我有一堆空值,并且phantomJS不会处理URL ......

请求:

object(JonnyW\PhantomJs\Http\Request)#113 (12) {
    ["type":protected]=> NULL
    ["headers":protected]=> array(0) {}
    ["settings":protected]=>
      array(1) {
        ["resourceTimeout"]=>
        int(5000)
      }
    ["cookies":protected]=>
      array(2) {
        ["add"]=>
        array(0) {
        }
        ["delete"]=>
        array(0) {
        }
      }
    ["data":protected]=>
      array(0) {
      }
    ["url":protected]=>
      string(59) "http://luclaverdure.com"
    ["method":protected]=>
      string(3) "GET"
    ["timeout":protected]=>
      NULL
    ["delay":protected]=>
      int(0)
    ["viewportWidth":protected]=>
      int(0)
    ["viewportHeight":protected]=>
      int(0)
    ["bodyStyles":protected]=>
      array(0) {
      }
}

响应:

object(JonnyW\PhantomJs\Http\Response)#263 (9) {
    ["headers"]=>
      NULL
    ["status"]=>
      NULL
    ["content"]=>
      NULL
    ["contentType"]=>
      NULL
    ["url"]=>
      NULL
    ["redirectURL"]=>
      NULL
    ["time"]=>
      NULL
    ["console"]=>
      NULL
    ["cookies"]=>
      NULL
}

它永远不会返回内容

请帮忙

编辑:日志:

  

string(1413)“2018-02-25T22:31:25 [DEBUG] CookieJar - 创建并将会   将cookie存储在:“cookies.txt”1 0x1b67967   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x1b67967] 2 0x1baaaf5   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x1baaaf5] 3 0x198c463   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x198c463] 4 0x1ab3982   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x1ab3982] 5 0x79abb9   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x79abb9] 6 0x76b6f9   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x76b6f9] 7 0x750a5d   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x750a5d] 8 0x41cd89   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x41cd89] 9 0x41f5c4   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x41f5c4] 10 0x415b86   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x415b86] 11 0x2b1fc0917b45   /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)   [0x2b1fc0917b45] 12 0x4176a1   / kunden /主页/ 0 / d220355082 / htdocs中/ bitme /型芯/作曲家/ bin中/ phantomjs()   [0x4176a1] PhantomJS已经崩溃。请阅读错误报告指南   在http://phantomjs.org/bug-reporting.html并提交错误报告。         分段错误“int(0)NULL

编辑:

如果我用最新下载替换phantomJS,

我得到libicui18n.so.55缺少依赖

如何使用Composer安装它?

请注意,这需要安装在共享主机上,因此我没有root / sudo访问权限

感谢所有帮助。

1 个答案:

答案 0 :(得分:2)

检查你的系统是否运行SELinux(你可以用ClassCastException检查) - 它可以(并且它会)试图伤害PhantomJS,它看起来就像那样。

查看phantomjs.org/troubleshooting上的“ SELinux ”部分以获取官方解决方案。

相关问题