Install PhantomJS Ubuntu 18.04

Install PhantomJS Ubuntu 18.04

PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

PhantomJS is an optimal solution for Headless Website Testing, Screen Capture, Page Automation and Network Monitoring.

There can be several ways of installing PhantomJS on Ubuntu 18.04:

Install PhantomJS on Ubuntu 18.04 LTS using Terminal

Step 1: Update Package List

$ sudo apt-get update

Step 2: Install following Libs

$ sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
$ sudo apt-get install libfreetype6 libfreetype6-dev -y
$ sudo apt-get install libfontconfig1 libfontconfig1-dev -y

Step 3: Export File

$ export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"

Step 4: Download file

$ wget$PHANTOM_JS.tar.bz2

Step 5: Extract file

$ sudo tar xvjf $PHANTOM_JS.tar.bz2

Step 6: Move to share directory

$ sudo mv $PHANTOM_JS /usr/local/share

Step 7:

$ sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

Step 8: Check Installed Version

$ phantomjs --version
Standard (Image)