CentOS下安装phantomjs

phantomjs真强悍,不过官网的安装说明是真差劲,还是自己整理一份以备后用吧。
1 下载链接:
https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
下载解压到/usr/local/phantomjs目录下
(在本机用迅雷下载,然后上传到服务器,可以节约很多时间)

2 解压:

# tar jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2

3 确认版本,测试可用:

# cd /usr/local/phantomjs/bin
# ./phantomjs --version

如果出现以下错误:
./phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

则需要安装fontconfig:

yum -y install fontconfig

4 修改环境变量,随时随地执行phantomjs命令:

#vi /etc/profile

增加一行:
export PATH=/usr/local/phantomjs/bin:$PATH

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。