Unless it is absolutely necessary to build PhantomJS from source, it is highly recommended to download and install the ready-made binary package instead.
- RAM: at least 4 GB
- Disk space: at least 3 GB
- CPU: 1.8 GHz, 4 cores or more
PhantomJS is still a web browser, but headless (no GUI). Thus, building it from source takes a long time (mainly due to thousands of files in the WebKit module). Estimated build time for a 4-core system is 30 minutes.
First, install the development packages of the following tools and libraries:
icu. The actual package names may vary from one distribution to another.
On Debian-based distro (tested on Ubuntu 16.04 and Debian 9.0), run:
sudo apt-get install build-essential g++ flex bison gperf ruby perl \ libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \ libpng-dev libjpeg-dev python libx11-dev libxext-dev ttf-mscorefonts-installer
On Fedora-based distro (tested on CentOS 7.3), run:
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
You must have
PATH. Also, note that Git comes with it’s own version of
perl.exe. If you have both Git and a separate perl installation in your PATH, please make sure that you separate Perl install’s
bin folder comes before the git’s
bin folder in your PATH.
Please also add the folder
<phantomjs_path>\src\qt\3rdparty\gnuwin32\bin to your
PATH, as required tools such as
gperf will not be found otherwise.
Run the build script from Visual Studio Command Prompt.
Tip: Enabling incremental linking will make the linkage process faster.
OS X requirements
- Xcode and the necessary SDK for development (gcc, various tools, libraries, etc)
- OpenSSL via Homebrew or via MacPorts
Build PhantomJS from the FreeBSD Ports Collection: svnweb.freebsd.org/ports/head/lang/phantomjs/
Getting the Code
git clone git://github.com/ariya/phantomjs.git cd phantomjs git checkout <version-number> git submodule init git submodule update
Compile and Link
From the system console as normal user (no root):
Please be patient as this will take some time. Once it completes, the executable will be available under the
Tip: If the compilation process is interrupted, once started again the
build.py script will continue where left off.