How to Install PhantomJS on Ubuntu 16.04

Introduction

PhantomJS is a scripted, headless browser that can be used for automating web page interaction. PhantomJS is a free, open source and distributed under the BSD license. PhantomJS is based on WebKit and is very similar browsing environment to Safari and Google Chrome. The PhantomJS JavaScript API can be used to open web pages, execute user actions and take screenshots.

In this tutorial, we will learn how to install PhantomJS in Ubuntu 16.04 server.

Prerequisites

Step 1: Update the system

Before starting, it is recommended to update the system with the latest stable release. You can do this with the following command:

sudo apt-get update -y
sudo apt-get upgrade -y
sudo shutdown -r now

Step 2: Install PhantomJS

Before installing PhantomJS, you will need to install some required packages on your system. You can install all of them with the following command:

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

Next, you will need to download the PhantomJS. You can download the latest stable version of the PhantomJS from their official website. Run the following command to download PhantomJS:

sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2

Once the download is complete, extract the downloaded archive file to desired system location:

sudo tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/

Next, create a symlink of PhantomJS binary file to systems bin dirctory:

sudo ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/

Step 3: Verify PhantomJS

PhantomJS is now installed on your system. You can now verify the installed version of PhantomJS with the following command:

phantomjs --version

You should see the following output:

2.1.1

You can also find the version of the PhantomJS from PhantomJS prompt as shown below:

phantomjs

You will get the phantomjs prompt:

phantomjs>

Now, run the following command to find the version details:

phantomjs> phantom.version

You should see the following output:

{
   "major": 2,
   "minor": 1,
   "patch": 1
}

That's it. You have successfully installed PhantomJS on Ubuntu 16.04 server.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值