Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wanelo-pair/5f8b080cf4733fb44441556fefe6ba61 to your computer and use it in GitHub Desktop.
Save wanelo-pair/5f8b080cf4733fb44441556fefe6ba61 to your computer and use it in GitHub Desktop.
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev

Install these packages needed by PhantomJS to work correctly.

sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev

Get it from the PhantomJS website.

cd ~
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

Once downloaded, move Phantomjs folder to /usr/local/share/ and create a symlink:

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

Now, It should have PhantomJS properly on your system.

phantomjs --version
#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
PHANTOM_VERSION="phantomjs-2.1.1"
ARCH=$(uname -m)
if ! [ $ARCH = "x86_64" ]; then
$ARCH="i686"
fi
PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"
apt-get install build-essential chrpath libssl-dev libxft-dev -y
apt-get install libfreetype6 libfreetype6-dev -y
apt-get install libfontconfig1 libfontconfig1-dev -y
cd ~
curl -L -o $PHANTOM_JS.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
tar xvjf $PHANTOM_JS.tar.bz2
mv $PHANTOM_JS /usr/local/share
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment