sh 如何在Debian / Ubuntu上安装PhantomJS

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 如何在Debian / Ubuntu上安装PhantomJS相关的知识,希望对你有一定的参考价值。

# 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](http://phantomjs.org/).

	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-1.9.8"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
	$ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

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

cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

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

以上是关于sh 如何在Debian / Ubuntu上安装PhantomJS的主要内容,如果未能解决你的问题,请参考以下文章

sh 如何在Debian / Ubuntu上安装Nginx和Google PageSpeed

sh 在Debian / Ubuntu Linux上安装Azure CLI

sh 使用apt-get在Ubuntu 14.04上安装Scala 2.11.7和SBT 0.13.9或使用apt-get安装任何Debian衍生产品

sh Debian / Ubuntu Tarsnap安装

sh 适用于Linux Debian / Ubuntu的Drupal安装脚本

如何在 Debian / Ubuntu 服务器上架设 L2TP / IPSec VPN