Installing PhantomJS on Ubuntu 12.04 LTS

PhantomJS is a headless WebKit browser that is scriptable with a JavaScript API. This article will walk you through installing it on your Ubuntu Pod on Solar VPS.

First, ssh to your pod and change directories to /usr/local/share:

root@mypod:~# cd /usr/local/share

Once there, we’ll use wget to download the latest version of PhantomJS. At the time of this article, the latest version of PhantomJS is 1.9. For this example, we will be installing that version, and will show 32bit and 64bit examples. If there is a newer version available, adjust filenames accordingly, and make sure to use either the 32bit or 64bit version depending on what OS you are using.

You must download either the 64bit or 32bit binaries, depending on whether you are using 64bit or 32bit Ubuntu:

For 64 bit:
root@mypod:~# sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
OR, for 32 bit:
root@mypod:~# sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-i686.tar.bz2

Extract the files:

For 64 bit:
root@mypod:~# sudo tar xjf phantomjs-1.9.0-linux-x86_64.tar.bz2
OR, for 32 bit:
root@mypod:~# sudo tar xjf phantomjs-1.9.0-linux-i686.tar.bz2

We’ll now link to phantomjs so that it can be ran from anywhere:

For 64 bit:
root@mypod:~# sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/bin/phantomjs

OR, for 32 bit:
root@mypod:~# sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-i686/bin/phantomjs /usr/local/share/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-i686/bin/phantomjs /usr/local/bin/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-i686/bin/phantomjs /usr/bin/phantomjs

Finally, install this dependency:

root@mypod:~# sudo apt-get install fontconfig

You can test that Phantom has installed correctly by running:

root@mypod:~# phantomjs --version

Matthew McCaffrey

Leave a Reply