Linux下安裝Phantomjs


1. 安裝linux系統的軟件包

先來看一下官方網站的提示:

Note: For this static build, the binary is self-contained. There is no requirement to install Qt, WebKit, or any other libraries. It however still relies on Fontconfig (the package fontconfig or libfontconfig, depending on the distribution). The system must have GLIBCXX_3.4.9 and GLIBC_2.7.
上面是官方網站的說明:phantomjs不依賴過多的包,但是根據linux的版本不同,可能依賴fontconfig或者libfontconfig
Centos系列版本的linux依賴fontconfig這個軟件包,Ubuntu系列版本的linux依賴libfontconfig這個軟件包。

Centos的依賴包安裝命令:

sudo yum install gcc gcc-c++ make git openssl-devel freetype-devel fontconfig-devel 

其中主要是fontconfig-devel,只要你的linux系統不是裸系統,其他的都應該有了。

Ubuntu的依賴包安裝命令:

sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev libxft-dev

其中主要是libfontconfig1-dev

2. 下載安裝phantomjs

下載鏈接:wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2

wget后面的連接是從官方網站獲得的,根據自己的os的型號和位數找到對應的下載地址。

解壓文件:

tar -xvf phantomjs-1.9.7-linux-x86_64.tar.bz2

將程序移到一個合適的位置:

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

創建軟鏈接到環境變量中。這樣可以直接在shell中使用phantomjs命令:

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

其中的參數s表示為軟鏈接,參數f表示強制。

檢查是否正常工作:

phantomjs –version

如果你看到當前版本號,即表示正常工作了。

3. 參考鏈接

  1. http://www.lao8.org/article_1547/phantomjs_centos_linux
  2. http://ju.outofmemory.cn/entry/70691
  3. 官方地址:http://phantomjs.org/download.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM