- Install the required dependencies for PhantomJS:
sudo yum install freetype freetype-devel fontconfig
Download the PhantomJS binary for Linux from the official website: http://phantomjs.org/download.html (or in this case PhantomJS 2.1.1 version)
Extract the downloaded tar file:
tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2
- Move the extracted folder to /usr/local/share:
sudo mv phantomjs-2.1.1-linux-x86_64/ /usr/local/share/
- Create a symlink of the PhantomJS executable to /usr/local/bin:
sudo ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
- Verify the installation by running:
phantomjs --version
It should display the version of PhantomJS that you have installed (2.1.1).
Note:
- You can also install other extension that support PhantomJS like
slimerjsortriflejs - You need to have Node.js installed on your machine to be able to use npm commands
- Also in case you are facing issues with fonts, you can install ttf-mscorefonts-installer package which provides commonly used Microsoft fonts.
sudo yum install ttf-mscorefonts-installer
And if you are installing PhantomJS for web scraping, you may need to install additional libraries such as beautifulsoup4 and requests.
You can install them via pip
pip install beautifulsoup4pip install requests