How can I setup & run PhantomJS on Ubuntu?

2019-01-03 19:11发布

I set up PhantomJS and recorded it to video: https://www.dailymotion.com/video/xnizmh_1_webcam

Build instructions: http://phantomjs.org/build.html

Is there anything wrong in my setup?

After I set it up I read the quick start tutorial and tried to write this code

phantomjs hello.js 

It gives me "command not found" error. How can I solve this problem?

25条回答
一夜七次
2楼-- · 2019-01-03 20:00

Or the latest - 32bit version Linux

sudo wget http://phantomjs.googlecode.com/files/phantomjs-1.9.2-linux-i686.tar.bz2

sudo ln -s /usr/local/share/phantomjs-1.9.2-linux-i686/bin/phantomjs /usr/local/share/phantomjs

sudo ln -s /usr/local/share/phantomjs-1.9.2-linux-i686/bin/phantomjs /usr/local/bin/phantomjs

sudo ln -s /usr/local/share/phantomjs-1.9.2-linux-i686/bin/phantomjs /usr/bin/phantomjs
查看更多
冷血范
3楼-- · 2019-01-03 20:01

download from phantomjs website the prebuilt package : http://phantomjs.org/download.html then open a terminal and go to the Downloads folder

sudo mv phantomjs-1.8.1-linux-x86_64.tar.bz2 /usr/local/share/.
cd /usr/local/share/
sudo tar xjf phantomjs-1.8.1-linux-x86_64.tar.bz2
sudo ln -s /usr/local/share/phantomjs-1.8.1-linux-x86_64 /usr/local/share/phantomjs
sudo ln -s /usr/local/share/phantomjs/bin/phantomjs /usr/local/bin/phantomjs

then to check install phantomjs -v should return 1.8.1

查看更多
爷、活的狠高调
4楼-- · 2019-01-03 20:03

I know this is too old, but, just i case someone gets to this question from Google now, you can install it by typing apt-get install phantomjs

查看更多
混吃等死
5楼-- · 2019-01-03 20:04

Here is what I did on my ubuntu 16.04 machine

sudo apt-get update
sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo mv path/where/you/downloaded/phantomjs  /usr/bin

and finally when I do

phantomjs -v

I get 2.1.1

After going through every answer of this thread. I think this is the best solution for installing and running phantomjs in ubuntu.

查看更多
放荡不羁爱自由
6楼-- · 2019-01-03 20:05

PhantomJS is on npm. You can run this command to install it globally:

npm install -g phantomjs-prebuilt  

phantomjs -v should return 2.1.1

查看更多
Anthone
7楼-- · 2019-01-03 20:05

On Ubuntu for Windows, I found neither apt-get nor npm versions worked for me. What worked was the script from this comment.

For ease of use, I pasted the whole thing into a script file called install_phantomjs.sh, made it executable (chmod u+x install_phantomjs.sh), and then ran it (./install_phantomjs.sh)

查看更多
登录 后发表回答