Home » Php » php – Installing PhantomJS on shared hosting (1and1)

php – Installing PhantomJS on shared hosting (1and1)

Posted by: admin July 12, 2020 Leave a comment

Questions:

Using 1and1 linux shared hosting,

I have installed:

PHP Version 7.0.27
PHP PhantomJS 2.1.1

PHP PhantomJS all values are null

Whenever I make a request with:

$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);
}

I have a bunch of null values and the URL doesn’t get processed by phantomJS…

Request:

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) {
      }
}

Response:

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
}

It just never returns content

Please help

Edit: Logs:

string(1413) “2018-02-25T22:31:25 [DEBUG] CookieJar – Created and will
store cookies in: “cookies.txt” 1 0x1b67967
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x1b67967] 2 0x1baaaf5
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x1baaaf5] 3 0x198c463
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x198c463] 4 0x1ab3982
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x1ab3982] 5 0x79abb9
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x79abb9] 6 0x76b6f9
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x76b6f9] 7 0x750a5d
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x750a5d] 8 0x41cd89
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x41cd89] 9 0x41f5c4
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x41f5c4] 10 0x415b86
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x415b86] 11 0x2b1fc0917b45
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)
[0x2b1fc0917b45] 12 0x4176a1
/kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs()
[0x4176a1] PhantomJS has crashed. Please read the bug reporting guide
at http://phantomjs.org/bug-reporting.html and file a bug report.
Segmentation fault ” int(0) NULL

Edit:

If I replace the phantomJS with latest download,

I get libicui18n.so.55 missing dependency

how can I install this with Composer?

Please note that this needs to be installed on a shared hosting machine, hence I do not have root/sudo access on the machine

All help is appreciated.

How to&Answers:

Check if your system runs SELinux (you can check that with sestatus) —- it can (and it will) try to harm PhantomJS, and it looks just like that.

Check out “SELinux” section on phantomjs.org/troubleshooting for official solution.