linux phantomjs 安装

下载64位 phantomjs,我的机器是64位

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
由于网络问题,附上百度云盘连接
链接: https://pan.baidu.com/s/1Ourt2gN-zR8wh1Ecq0wrFg 提取码: q149

解压文件

[downloads] tar -xvf phantomjs-2.1.1-linux-x86_64.tar.bz2                                                                                                                                                11:29:10 
phantomjs-2.1.1-linux-x86_64/
phantomjs-2.1.1-linux-x86_64/examples/
phantomjs-2.1.1-linux-x86_64/examples/colorwheel.js
phantomjs-2.1.1-linux-x86_64/examples/scandir.js
phantomjs-2.1.1-linux-x86_64/examples/page_events.js
phantomjs-2.1.1-linux-x86_64/examples/loadspeed.js
phantomjs-2.1.1-linux-x86_64/examples/injectme.js
phantomjs-2.1.1-linux-x86_64/examples/render_multi_url.js
phantomjs-2.1.1-linux-x86_64/examples/server.js
phantomjs-2.1.1-linux-x86_64/examples/netlog.js
phantomjs-2.1.1-linux-x86_64/examples/pagecallback.js
phantomjs-2.1.1-linux-x86_64/examples/module.js
phantomjs-2.1.1-linux-x86_64/examples/arguments.js
phantomjs-2.1.1-linux-x86_64/examples/universe.js
phantomjs-2.1.1-linux-x86_64/examples/openurlwithproxy.js
phantomjs-2.1.1-linux-x86_64/examples/sleepsort.js
phantomjs-2.1.1-linux-x86_64/examples/modernizr.js
phantomjs-2.1.1-linux-x86_64/examples/unrandomize.js
phantomjs-2.1.1-linux-x86_64/examples/hello.js
phantomjs-2.1.1-linux-x86_64/examples/stdin-stdout-stderr.js
phantomjs-2.1.1-linux-x86_64/examples/fibo.js
phantomjs-2.1.1-linux-x86_64/examples/phantomwebintro.js
phantomjs-2.1.1-linux-x86_64/examples/echoToFile.js
phantomjs-2.1.1-linux-x86_64/examples/post.js
phantomjs-2.1.1-linux-x86_64/examples/loadurlwithoutcss.js
phantomjs-2.1.1-linux-x86_64/examples/child_process-examples.js
phantomjs-2.1.1-linux-x86_64/examples/printenv.js
phantomjs-2.1.1-linux-x86_64/examples/useragent.js
phantomjs-2.1.1-linux-x86_64/examples/rasterize.js
phantomjs-2.1.1-linux-x86_64/examples/outputEncoding.js
phantomjs-2.1.1-linux-x86_64/examples/waitfor.js
phantomjs-2.1.1-linux-x86_64/examples/serverkeepalive.js
phantomjs-2.1.1-linux-x86_64/examples/postserver.js
phantomjs-2.1.1-linux-x86_64/examples/printmargins.js
phantomjs-2.1.1-linux-x86_64/examples/version.js
phantomjs-2.1.1-linux-x86_64/examples/run-qunit.js
phantomjs-2.1.1-linux-x86_64/examples/features.js
phantomjs-2.1.1-linux-x86_64/examples/netsniff.js
phantomjs-2.1.1-linux-x86_64/examples/walk_through_frames.js
phantomjs-2.1.1-linux-x86_64/examples/printheaderfooter.js
phantomjs-2.1.1-linux-x86_64/examples/responsive-screenshot.js
phantomjs-2.1.1-linux-x86_64/examples/countdown.js
phantomjs-2.1.1-linux-x86_64/examples/detectsniff.js
phantomjs-2.1.1-linux-x86_64/examples/simpleserver.js
phantomjs-2.1.1-linux-x86_64/examples/postjson.js
phantomjs-2.1.1-linux-x86_64/examples/run-jasmine2.js
phantomjs-2.1.1-linux-x86_64/examples/run-jasmine.js
phantomjs-2.1.1-linux-x86_64/README.md
phantomjs-2.1.1-linux-x86_64/LICENSE.BSD
phantomjs-2.1.1-linux-x86_64/bin/
phantomjs-2.1.1-linux-x86_64/bin/phantomjs
phantomjs-2.1.1-linux-x86_64/third-party.txt
phantomjs-2.1.1-linux-x86_64/ChangeLog

改名并移动到目录(根据个人行为爱好)

mv phantomjs-2.1.1-linux-x86_64 phantomjs
sudo mv phantomjs /usr/local/src/

建立软连接

sudo ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/bin/phantomjs

测试是否安装好(请重新打开一个终端)

[~] phantomjs                                                                                                                                                                                             
phantomjs> 

ok...

若出现

phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

请执行

sudo apt-get install fontconfig
原文地址:https://www.cnblogs.com/dockers/p/10522107.html