一、下载地址
http://phantomjs.org/download.html
找到linux版本下载地址下载
或者运行下面命令下载:
1,wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
二、解压
2,tar -jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2
如果解压报错,可能系统没有安装bzip2,先执行下面命令安装
yum install bzip2.x86_64
三、配置环境变量
3.[root@localhost local]# sudo vi /etc/profile
文件末尾增加如下内容,具体路径按实际情况设置
4,export PATH=$PATH:/usr/local/phantomjs-2.1.1-linux-x86_64/bin
执行下面命令,环境变量生效
5,[root@localhost local]# source /etc/profile
在执行下面命令,输出2.1.1,表示安装成功
6.[root@localhost local]# phantomjs --version
总结如下:
-
首先解压下载好的zip文件或tar文件(linux only);
-
windows用户将解压过后的得到的phantomjs.exe文件加入系统的PATH中。简单点说如果你使用pyhon,就把phantomjs.exe放到python的安装目录下,ruby用户放到ruby/bin目录下;
-
mac和linux用户可以把解压后得到的phantomjs建个软链到/usr/local/bin目录下。
ln -s /where/is/phantomjs /usr/local/bin/phantomjs(有了此步骤就不用配置以上的环境变量,也就是只需要前面的1、2步再加上ln -s这一步就够了,然而你得找出phantomsjs的位置所在)
参考链接:http://blog.csdn.net/qinglu000/article/details/52243369
http://www.jianshu.com/p/573dc94fb3ca