Compiling phantomJs 2.0 binaries on Linux

Posted by Matt Bryson on 08-Feb-2015 16:56:26
Find me on:

We were upgrading our automated screen shot process of our core product, moving it over to phantomJS 2.0 as it uses a much newer QT WebKit engine, that produces far more accurate results.

However, there is currently no download for the linux build, so we decided to build it ourselves. After quite a few failed attempts, (using various bash scripts and trying the deploy vm that is in the repo), this is how we finally got it working If you want to cut to the chase, you can grab the 64bit bin file here...

UPDATE: for compiling for AWS EC2 see here

We used Virtualbox and vagrant on OSX to spin up a 64bit CentOS box, with this vagrant file.

Note the memory allocation, the build will fail unless you have decent amount of ram on the VM
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = "CentOS_6.5_64"
config.vm.box_url = ""
config.vm.synced_folder ".", "/home/vagrant/phantomjs/bin", owner:"root", group:"root", mount_options:["dmode=777","fmode=777"]

config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]

Save the above and call it Vagrantfile. Then get your terminal up, and cd to the same dir.

Now spin up that server and ssh into it (the first time will take a while as it downloads the base vm image)...
vagrant up
vagrant ssh
Then update yum and install dependencies...
 sudo yum -y update
sudo yum -y install gcc gcc-c++ make flex bison gperf ruby openssl-devel freetype-devel
fontconfig-devel libicu-devel sqlite-devel libpng-devel libjpeg-devel

Checkout the repo, and switch to the 2.0 release
 git clone git://
cd phantomjs
git checkout 2.0.0
Next we had to patch the 2.0 release with a bug fix
 curl -O
git apply 12899.patch
And finally run the build script.

It takes HOURS to compile, due to all the webkit dependencies. We did try spinning up with more CPU cores, and running the build script with more build jobs, but this always failed on us.

If you just want the bin from this build (64bit) then you can grab it here


Topics: PhantomJS, Linux

About the author

Matt Bryson is an experienced systems engineer with over 15 years Development and Systems Operations experience.

Product Briefing

In this short product briefing, see how iDetailAid customers are simplifying the creation, update, localisation and upload of CLM content.

New Call-to-action

Subscribe to Email Updates

Recent Posts