It would be great if there was a PhantomJS package for Debian or Ubuntu so you could just install it by typing apt-get install phantomjs. But there's not.

Luckily, though, someone created some good instructions on how to install PhantomJS on those operating systems, and then, another person took those instructions and made them into a nice and easy PhantomJS install script for Debian and Ubuntu.

I haven't tried it yet on Ubuntu, but I've already installed PhantomJS with it on Debian 7. And it works without a hitch.

Here is how to install PhantomJS with this easy install script. You can preface all commands with sudo if you have sudo installed. Otherwise, do this with root privileges.

  1. Open a command prompt and go to a directory where you want to do this. I chose /tmp
  2. Run wget https://gist.githubusercontent.com/talpa/16db1b8cfd3148364e19/raw/7f9a21847b1a75bb8207aba04d37432dfa2be411/install_phantomjs.sh to download the install script.
  3. Run chmod +x install_phantomjs.sh to make the script executable.
  4. Then run ./install_phantomjs.sh to run the install script.

The script will then run and then you will have PhantomJS on your system.