先前在 ubuntu 上安裝 phantomjs 屢屢失敗,第一次安裝立馬使用 "apt-get" 搜尋,找到後就很放心的安裝,沒想到裝完後還是沒辦法正常使用,後來去 phantom 官方找,官方也提供了一套安裝方式,但還是有問題,還好我有個好朋友叫 google
下面這段 script 的 3-7 行其實是在反安裝 phantomjs 從 apt-get 的版本, 9-15 行為重新安裝 phantomjs 並設定位置,17 行為確認目前 phantom 版本、安裝狀況
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get remove phantomjs | |
sudo unlink /usr/local/bin/phantomjs | |
sudo unlink /usr/local/share/phantomjs | |
sudo unlink /usr/bin/phantomjs | |
cd /usr/local/share | |
sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2 | |
tar xjf phantomjs-1.9.0-linux-x86_64.tar.bz2 | |
sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/bin/phantomjs | |
phantomjs -v |
其中特別要注意的就是 phantomjs 以及 ubuntu 的版本,必須依照所需來調整
32-bit: phantomjs-1.9.0-linux-i686.tar.bz2
64-bit: phantomjs-1.9.0-linux-x86_64.tar.bz2