How to install Phantomjs 2.1.1 on Ubuntu 18.04

To install Phantomjs 2.1.1 on Ubuntu 18.04

Phantomjs is free and open source Scripted, headless browser used for automation of web page interaction. Phantomjs in licensed under BSD license and enables the automated navigation, screenshots and user behavior. The browsing environment of phantomjs is very similar to Safari and Google Chrome.

Installation

Now download  a package using this following URL

root@linuxhelp1:~# wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
--2018-05-04 18:26:13--  https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
Resolving bitbucket.org (bitbucket.org)... 104.192.143.1, 104.192.143.2, 104.192.143.3, ...
Connecting to bitbucket.org (bitbucket.org)|104.192.143.1|:443... connected.
.
.
HTTP request sent, awaiting response... 200 OK
Length: 23415665 (22M) [application/x-tar]
Saving to: ‘ phantomjs-2.1.1-linux-x86_64.tar.bz2’ 

phantomjs-2.1.1-linux-x 100%[==============================> ]  22.33M  70.2KB/s    in 4m 54s  

2018-05-04 18:31:10 (77.7 KB/s) - ‘ phantomjs-2.1.1-linux-x86_64.tar.bz2’  saved [23415665/23415665]

The downloaded package is a tar file, so  extract the package as follows

root@linuxhelp1:~# tar -xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 
phantomjs-2.1.1-linux-x86_64/
phantomjs-2.1.1-linux-x86_64/examples/
phantomjs-2.1.1-linux-x86_64/examples/colorwheel.js
phantomjs-2.1.1-linux-x86_64/examples/scandir.js
phantomjs-2.1.1-linux-x86_64/examples/page_events.js
phantomjs-2.1.1-linux-x86_64/examples/loadspeed.js
.
.
phantomjs-2.1.1-linux-x86_64/examples/run-jasmine.js
phantomjs-2.1.1-linux-x86_64/README.md
phantomjs-2.1.1-linux-x86_64/LICENSE.BSD
phantomjs-2.1.1-linux-x86_64/bin/
phantomjs-2.1.1-linux-x86_64/bin/phantomjs
phantomjs-2.1.1-linux-x86_64/third-party.txt
phantomjs-2.1.1-linux-x86_64/ChangeLog

Run the following command to generate the link for Phatomjs execution

root@linuxhelp1:~# ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin

verify the  Phantomjs version using the following command

root@linuxhelp1:~# phantomjs --version
2.1.1

Open Phantomjs console and check the version

root@linuxhelp1:~# phantomjs 
phantomjs>  phantom.version
{
   " major" : 2,
   " minor" : 1,
   " patch" : 1
}

with this, the method to install  Phantomjs 2.1.1 on Ubuntu 18.04 comes to an end.

FAQ
Q
How does the browsing environment of PhantomJs look alike?
A
The browsing environment of phantomjs is very similar to Safari and Google Chrome.
Q
What is Phantomjs?
A
Phantomjs is free and open source Scripted, headless browser used for automation of web page interaction. Phantomjs in licensed under BSD license and enables the automated navigation, screenshots and user behavior.
Q
what are the supported platforms for phantomjs?
A
The Platforms in which Phantomjs works are, Windows, Linux, and Mac OS.
Q
Why do I get the error message phantomjs: cannot connect to X server?
A
In PhantomJS 1.4 or earlier, X server is still needed. The workaround is to use Xvfb. Starting with PhantomJS 1.5, it is pure headless and there is no need to run X11/Xvfb anymore.
Q
Which WebKit version is used by PhantomJS?
A
If you want to know HTML5/CSS3/other features supported by PhantomJS, using WebKit version is not a good idea. See Supported Web Standards documentation page for details.