PhantomJS isn’t available from the standard Amazon Linux yum repository. Follow these steps to download a binary distribution of PhantomJS and install it on a server running Amazon Linux.

1
2
3
4
5
6
7
sudo yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
sudo mkdir -p /opt/phantomjs
bzip2 -d phantomjs-1.9.8-linux-x86_64.tar.bz2
sudo tar -xvf phantomjs-1.9.8-linux-x86_64.tar \
    --directory /opt/phantomjs/ --strip-components 1
sudo ln -s /opt/phantomjs/bin/phantomjs /usr/bin/phantomjs

Once complete, run the following command to verify the installation:

1
phantomjs /opt/phantomjs/examples/hello.js