Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev

Install these packages needed by PhantomJS to work correctly.

sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev

Get it from the PhantomJS website.

cd ~
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

Once downloaded, move Phantomjs folder to /usr/local/share/ and create a symlink:

sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

Now, It should have PhantomJS properly on your system.

phantomjs --version
#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
PHANTOM_VERSION="phantomjs-1.9.8"
ARCH=$(uname -m)
if ! [ $ARCH = "x86_64" ]; then
$ARCH="i686"
fi
PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y
cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
@tcardonne

This comment has been minimized.

tcardonne commented Sep 2, 2014

There is a mistake :

sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/
cd /usr/local/share/
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs

should be :

sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/
cd /usr/local/share/
sudo tar xvjf phantomjs-1.9.2-linux-x86_64.tar.bz2
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs
@aminelaadhari

This comment has been minimized.

@julionc

This comment has been minimized.

Owner

julionc commented Sep 30, 2014

good catch!
I updated the gist. Thank you guys!

@karol-blaszczyk

This comment has been minimized.

karol-blaszczyk commented Oct 1, 2014

Thank you, that was i was looking for !

@SizeSeeker

This comment has been minimized.

SizeSeeker commented Oct 8, 2014

Great gist, thank you!

@shamabbas

This comment has been minimized.

shamabbas commented Oct 27, 2014

Great! Thank you!

@iobee

This comment has been minimized.

iobee commented Nov 19, 2014

Great! Thank you!

@lucassch

This comment has been minimized.

lucassch commented Nov 26, 2014

Great!

@reminate

This comment has been minimized.

reminate commented Dec 9, 2014

Thank you!

@nikulkarni

This comment has been minimized.

nikulkarni commented Dec 15, 2014

exactly what I was looking for, thank you.

@georgehenze

This comment has been minimized.

georgehenze commented Dec 27, 2014

Thanks a lot!

@talpa

This comment has been minimized.

talpa commented Jan 4, 2015

@idmontie

This comment has been minimized.

idmontie commented Jan 10, 2015

👍
Thanks for this write up. Note that Phantom is now on 1.9.8 though.

@augnustin

This comment has been minimized.

augnustin commented Jan 20, 2015

Why triple symbolic link? Just in case?

What about sudo apt-get install phantomjs? It did not work for me, but any idea why?

@Yakito

This comment has been minimized.

Yakito commented Feb 3, 2015

Tested on an EC2 with Ubuntu 14.04, Works fine.

@lethalbrains

This comment has been minimized.

lethalbrains commented Feb 5, 2015

Thanx

@tbuchboeck

This comment has been minimized.

tbuchboeck commented Feb 5, 2015

JFYI:
We had some font issues recently (Debian GNU/Linux 7.8 (wheezy) pjs-1.9.7)
Installing sudo apt-get install msttcorefonts solved the problem.

@q0rban

This comment has been minimized.

q0rban commented Feb 5, 2015

Thanks for this! You shouldn't need to create that many symlinks, or export your $PHANTOM_JS variable. I would just symlink to /usr/local/bin.

@q0rban

This comment has been minimized.

q0rban commented Feb 5, 2015

Here's a shorter version of the above:

sudo aptitude update
sudo aptitude install build-essential chrpath libssl-dev libxft-dev \
  libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
tar -xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -s /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
phantomjs --version
@tunnckoCore

This comment has been minimized.

tunnckoCore commented Feb 6, 2015

After all

bash: /usr/local/bin/phantomjs: cannot execute binary file: Exec format error

Ubuntu 14.04

@tunnckoCore

This comment has been minimized.

tunnckoCore commented Feb 6, 2015

Its okey. It was the arch :)

@ghost

This comment has been minimized.

ghost commented Feb 13, 2015

q0rban: worked perfectly, thanks!

@pankajclabs

This comment has been minimized.

pankajclabs commented Feb 27, 2015

phantomjs --version

getting this:

Fontconfig warning: ignoring UTF-8: not a valid region tag
1.9.8

please help me out, I really tried everything

@mgzrobles

This comment has been minimized.

mgzrobles commented Mar 5, 2015

ubuntu
phantomjs --version
-bash: /usr/local/bin/phantomjs: cannot execute binary file

@jasseral

This comment has been minimized.

jasseral commented Mar 17, 2015

same !! :(
ubuntu
phantomjs --version
-bash: /usr/local/bin/phantomjs: cannot execute binary file

@jasseral

This comment has been minimized.

jasseral commented Mar 17, 2015

HELP !

@azenkovets

This comment has been minimized.

azenkovets commented Mar 18, 2015

Have the same issue:
phantomjs --version
-bash: /usr/local/bin/phantomjs: cannot execute binary file

@TammoHeeren

This comment has been minimized.

TammoHeeren commented Mar 18, 2015

you may need to download the i686 version
PHANTOM_JS="phantomjs-1.9.8-linux-i686"

@prakash89

This comment has been minimized.

prakash89 commented Mar 19, 2015

Ubuntu
phantomjs --version
-bash: /usr/local/bin/phantomjs: cannot execute binary file

@prakash89

This comment has been minimized.

prakash89 commented Mar 19, 2015

Thanks,
This works for me
PHANTOM_JS="phantomjs-1.9.8-linux-i686"

@julionc

This comment has been minimized.

Owner

julionc commented Mar 20, 2015

I update this gist to v1.9.8.
For lazy ones like us. I attached install_phantomjs.sh script. Have fun!

@Rolos

This comment has been minimized.

Rolos commented Mar 29, 2015

Works perfectly, many thanks!

@id-den

This comment has been minimized.

id-den commented Apr 9, 2015

Thanks!

@donaldali

This comment has been minimized.

donaldali commented Apr 13, 2015

Awesome

@dominiquedutra

This comment has been minimized.

dominiquedutra commented Apr 17, 2015

Great stuff, thanks.

@ericallard0

This comment has been minimized.

ericallard0 commented Apr 20, 2015

Thanks !

@nhattan

This comment has been minimized.

nhattan commented Apr 21, 2015

Thanks!

@IvRRimum

This comment has been minimized.

IvRRimum commented Apr 30, 2015

install_phantomjs.sh - Works like charm, Thanks!

@xcaliburs

This comment has been minimized.

xcaliburs commented May 1, 2015

Thank you. Works fine, tested on EC2 with Ubuntu 14.04.

@vdloo

This comment has been minimized.

vdloo commented May 6, 2015

thanks!

@kumarldh

This comment has been minimized.

kumarldh commented May 17, 2015

Or you can build it on your machine as suggested on the site and then follow instructions from this page where the author starts moving the folder.

@shashank-saxena

This comment has been minimized.

shashank-saxena commented May 21, 2015

Thanks a ton!!!

@NL9

This comment has been minimized.

NL9 commented May 29, 2015

Thank you!

For fonts issue I have to install ttf-mscorefonts-installer too.

@carltondickson

This comment has been minimized.

carltondickson commented May 29, 2015

Amazingly simple <3

@FurkanArslan

This comment has been minimized.

FurkanArslan commented Jun 3, 2015

Thank you very much man! ☺️

@ftcosta

This comment has been minimized.

ftcosta commented Jun 17, 2015

for Ubuntu14.04 and Mint

cd /usr/local/share
sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
sudo tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
## system wide
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs

phantomjs -v

v//carlosdeoliveira.guru

change the version from 1.9.7 to 1.9.8

@alaabatayneh

This comment has been minimized.

alaabatayneh commented Jun 17, 2015

Thanks ftcosta

@rbyelyy

This comment has been minimized.

rbyelyy commented Jun 26, 2015

Thanks. Works like a sharm ;-)

@n37r06u3

This comment has been minimized.

n37r06u3 commented Jul 18, 2015

npm install phantomjs -g

@hebbian

This comment has been minimized.

hebbian commented Jul 23, 2015

pankajclabs, I know that feel buddy, when no one helps out

@rga-odoo

This comment has been minimized.

rga-odoo commented Jul 23, 2015

Thank you 👍

@kafeltz

This comment has been minimized.

kafeltz commented Jul 28, 2015

The solution is so complex that I prefer using php -S localhost:80 for simple tests.

@lalitb

This comment has been minimized.

lalitb commented Aug 7, 2015

For all those who are getting error "Cannot execute binary file" , please note these instructions are only for 64 bit architecture. For 32 bit, you may have to build phantomjs from source.

@nroose

This comment has been minimized.

nroose commented Oct 27, 2015

Thanks for this!

@Deele

This comment has been minimized.

Deele commented Nov 10, 2015

Thank you! Just installed it in vagrant and it works.

@voodoorai2000

This comment has been minimized.

voodoorai2000 commented Nov 10, 2015

Thank you! It works 👍

@lu-ko

This comment has been minimized.

lu-ko commented Nov 12, 2015

Problem: Fontconfig warning: ignoring UTF-8: not a valid region tag
Fix was in my case very simple, just add following variable to my bash profile: LC_ALL=en_US.UTF-8

@tonnydulo

This comment has been minimized.

tonnydulo commented Nov 14, 2015

Thanks for This

@adrianparr

This comment has been minimized.

adrianparr commented Nov 16, 2015

Thanks for this. It worked for me.

@nando

This comment has been minimized.

nando commented Nov 24, 2015

👍

Thanks, thanks, thanks,
-- nando

@mwillerich

This comment has been minimized.

mwillerich commented Dec 9, 2015

on Ubuntu 14.04 apt-get install phantomjs installs version 1.9.0-1 successfully for me.

@avral

This comment has been minimized.

avral commented Dec 15, 2015

Thank you very much =)

@dimanyc

This comment has been minimized.

dimanyc commented Dec 24, 2015

works! Thanks!

@mkhusu

This comment has been minimized.

mkhusu commented Jan 4, 2016

amazing stuff!
Thanks so much! Have been trying to figure this out for quite some time now

@jerryjohnjacob

This comment has been minimized.

jerryjohnjacob commented Jan 4, 2016

Awesome!! 👍

@pette9

This comment has been minimized.

pette9 commented Jan 24, 2016

worked, Thank You 👍

@makshark

This comment has been minimized.

makshark commented Feb 7, 2016

nice

@rotatopoti

This comment has been minimized.

rotatopoti commented Feb 10, 2016

thanks

@lucas1

This comment has been minimized.

lucas1 commented Mar 7, 2016

Thanks

@aidankmcl

This comment has been minimized.

aidankmcl commented Mar 7, 2016

Just completed successfully with version 2.1.1, thanks!

@ethagnawl

This comment has been minimized.

ethagnawl commented Mar 7, 2016

Ha - and here I was worried this would be out-of-date...

But, seriously, this is incredibly useful. Thanks for putting it together and keeping it up-to-date!

@onliners

This comment has been minimized.

onliners commented Mar 15, 2016

Thanks a lot!

@stefnats

This comment has been minimized.

stefnats commented Mar 17, 2016

Thanks! :-)

@vivex

This comment has been minimized.

vivex commented Mar 28, 2016

Thanks

@MayankPratap

This comment has been minimized.

MayankPratap commented Apr 2, 2016

Thanks :)

@langri-sha

This comment has been minimized.

langri-sha commented Apr 2, 2016

Thanks 😻! Everyone, don't forget to look at the latest gist revision 📝

@sridharkalaibala

This comment has been minimized.

sridharkalaibala commented Apr 3, 2016

Thanks a lot friend :)

@rimidl

This comment has been minimized.

rimidl commented Apr 11, 2016

Thanks!

@natanaugusto

This comment has been minimized.

natanaugusto commented Apr 27, 2016

Thanks! Very helpful

@yanshiyason

This comment has been minimized.

yanshiyason commented May 1, 2016

Thanks!!!

@amihaiemil

This comment has been minimized.

amihaiemil commented May 2, 2016

Great! Thank you very much!

@andyxmas

This comment has been minimized.

andyxmas commented May 3, 2016

Worked like a charm on Ubuntu 14 getting version 2.1.1 of Phantom using https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2. Thanks!

@fawyna

This comment has been minimized.

fawyna commented May 19, 2016

Thanks for the simple guide!

@kennytilton

This comment has been minimized.

kennytilton commented May 20, 2016

Brilliant.

@ghprod

This comment has been minimized.

ghprod commented May 30, 2016

Thanks :)

@achmadns

This comment has been minimized.

achmadns commented May 31, 2016

Thanks.

@baras

This comment has been minimized.

baras commented Jun 8, 2016

wget from Bitbucket sometimes results in a "20 redirection exceeded" error.
I would wget from github instead ( and get a newer version 😄 )

export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2

and thanks for this Gist 👍

@JorgeRdg

This comment has been minimized.

JorgeRdg commented Jun 14, 2016

Thanks for the Gist!

@enfeizhan

This comment has been minimized.

enfeizhan commented Jul 10, 2016

My sincere thanks. Heaps of instructions on the web but only yours works to me perfectly.

@a1exlism

This comment has been minimized.

a1exlism commented Jul 14, 2016

Thanks for sharing.

@DanDvoracek

This comment has been minimized.

DanDvoracek commented Jul 20, 2016

Thanks!

@nisevi

This comment has been minimized.

nisevi commented Aug 1, 2016

👍

@milad145

This comment has been minimized.

milad145 commented Aug 8, 2016

how can i uninstall phantomjs?

@adamwlev

This comment has been minimized.

adamwlev commented Aug 9, 2016

Thank you!

@mathieujobin

This comment has been minimized.

mathieujobin commented Aug 16, 2016

Great script...
but this working curl command that worked for me

sudo curl --output /usr/local/bin/phantomjs https://s3.amazonaws.com/circle-downloads/phantomjs-2.1.1

from: https://discuss.circleci.com/t/add-phantomjs-2-1-1-to-the-platform/1755/4

@cankemik

This comment has been minimized.

cankemik commented Sep 5, 2016

@loretoparisi

This comment has been minimized.

loretoparisi commented Sep 5, 2016

So this is the updated script for 2.1.1 and the new tarball url

#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#

if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

PHANTOM_VERSION="phantomjs-2.1.1"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
    $ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y

cd ~
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs
@capitolkrs

This comment has been minimized.

capitolkrs commented Sep 11, 2016

Thank you for the gist

@mikesten

This comment has been minimized.

mikesten commented Sep 13, 2016

@loretoparisi Thanks for the update! Small typo towards the end of your script...

sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/ should be sudo mv $PHANTOM_JS /usr/local/share/

@arturmalecki

This comment has been minimized.

arturmalecki commented Oct 5, 2016

Good stuff 👍

@juanpastas

This comment has been minimized.

juanpastas commented Oct 5, 2016

Thanks @mathieujobin

@miked0004

This comment has been minimized.

miked0004 commented Oct 7, 2016

Thanks for this. Since it runs as root, it does not need sudo.

I dumped this in a Dockerfile here: https://gist.github.com/miked0004/b4aa62b62afbb16c67528f7b5f520041

See the docker-compose.yml in that gist for an example of running the box to bundle and run rake.

@jmillxyz

This comment has been minimized.

jmillxyz commented Nov 1, 2016

Thanks @mikesten and @loretoparisi -- the bitbucket URL for wget does work for me.

@tregenza

This comment has been minimized.

tregenza commented Nov 19, 2016

Second to @mikesten comment on @loretoparisi 's script

sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/ should be sudo mv $PHANTOM_JS /usr/local/share/

Other than than the script works perfectly.

@FredyKonig

This comment has been minimized.

FredyKonig commented Nov 23, 2016

what about :
sudo apt-get install phantomjs

@rista404

This comment has been minimized.

rista404 commented Dec 2, 2016

Thanks @loretoparisi and @mikesten for the updated script, works great! 🎉

@ambikashri

This comment has been minimized.

ambikashri commented Dec 7, 2016

I am getting the below error. Could somebody suggest what could be done. I am using ubuntu

customer@QA-Ubuntu-1:~/automation$ phantomjs --webdriver=8090 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
QXcbConnection: Failed to initialize XRandr
Qt: XKEYBOARD extension not present on the X server.
[INFO - 2016-12-07T10:46:27.715Z] GhostDriver - Main - running on port 8090
[INFO - 2016-12-07T10:46:27.720Z] GhostDriver - Main - registering to Selenium HUB 'http://127.0.0.1:4444' version: using '127.0.0.1:8090' with org.openqa.grid.selenium.proxy.DefaultRemoteProxy as remote proxy. [ERROR - 2016-12-07T10:46:27.740Z] GhostDriver - main.fail - {"line":97,"stack":"register\nglobal code"}

@z

This comment has been minimized.

z commented Dec 18, 2016

The other update for 2.1.1 had issues, I modified the script below:

#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#

if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

PHANTOM_VERSION="phantomjs-2.1.1"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
    $ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y

cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

sudo mv $PHANTOM_JS /usr/local/share/
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs
@gautiermichelin

This comment has been minimized.

gautiermichelin commented Dec 28, 2016

If this script has to be run through a sudo, why the sudo lines at the end ?
It's redundant...

Prefer :

#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#

if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

PHANTOM_VERSION="phantomjs-2.1.1"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
    $ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

apt-get update
apt-get -y install build-essential chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev

cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
tar xvjf $PHANTOM_JS.tar.bz2
mv $PHANTOM_JS /usr/local/share/
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs

@julionc nice and very useful gist :-) 👍

@ssi-anik

This comment has been minimized.

ssi-anik commented Jan 22, 2017

👍 for the post, and if anyone wants to download the latest one, go get the file name, and change the PHANTOM_JS variable.

@illia108

This comment has been minimized.

illia108 commented Jan 26, 2017

Thanks. Worked for me!

@bologer

This comment has been minimized.

bologer commented Jan 26, 2017

Для тех, кто мучается установкой phantomjs 2.x.x на Ubuntu 14.00/if you cannot easily install phantomjs 2.x.x on Ubuntu — http://bologer.ru/kak-ustanovitobnovit-phantomjs-v-ubuntu-14-04/

@frankie-loves-jesus

This comment has been minimized.

frankie-loves-jesus commented Feb 4, 2017

Worked here as well, thanks for a wonderful thread!

@siddhantsomani

This comment has been minimized.

siddhantsomani commented Mar 15, 2017

Worked perfectly !
Thanks !!

@janipaijanen

This comment has been minimized.

janipaijanen commented Mar 17, 2017

There happened something in the download for me and being lazy to cleaning up things, I thought it would be better to force things happen.

For phantomjs-2.1.1

#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#

if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

PHANTOM_VERSION="phantomjs-2.1.1"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
    $ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

apt-get update
apt-get -y install build-essential chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev

cd ~
wget -q https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 -O $PHANTOM_JS.tar.bz2
tar xvjf $PHANTOM_JS.tar.bz2

if [ -d /usr/local/share/$PHANTOM_JS ] ; then
  rm -rf /usr/local/share/$PHANTOM_JS
fi
mv -f $PHANTOM_JS /usr/local/share/
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs

@Lgofk

This comment has been minimized.

Lgofk commented Apr 14, 2017

very helpful! Thanks ;)

@diego-augusto

This comment has been minimized.

diego-augusto commented Apr 25, 2017

Thanks!

@alihesari

This comment has been minimized.

alihesari commented Apr 28, 2017

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

npm install -g phantomjs-prebuilt

@mbriceno

This comment has been minimized.

mbriceno commented May 15, 2017

Perfect! thank a lot!!

@skylerto

This comment has been minimized.

skylerto commented Jun 5, 2017

❤️

@nateGeorge

This comment has been minimized.

nateGeorge commented Jun 13, 2017

Dude, awesome. Would be cool though if it grabbed the latest version automatically, since now we're at 2.1.1. But I guess if npm works, then that is easier than writing your own script.

@bchschaefer

This comment has been minimized.

bchschaefer commented Jul 24, 2017

@nateGeorge

Just my quick&dirty one liner to grab the latest, non-beta, 64bit archive name:

PHANTOM_JS_LATEST=$(curl -s https://bitbucket.org/ariya/phantomjs/downloads/ | grep -i -e zip -e bz2 | grep -vi beta | grep -i linux-x86_64 | grep -v symbols | cut -d '>' -f 2 | cut -d '<' -f 1 | head -n 1)

@pedrocaseiro

This comment has been minimized.

pedrocaseiro commented Aug 31, 2017

Awesome!

@Unayung

This comment has been minimized.

Unayung commented Sep 5, 2017

Thank you so much !!!! @janipaijanen. ❤️ ❤️ ❤️

@ManuelTS

This comment has been minimized.

ManuelTS commented Sep 28, 2017

With the version of @janipaijanen you will have the tar.bz2 file lying around in your home folder. I used /tmp/ instead to delete it automatically when the computer shuts down.

Thanks a ton @janipaijanen!

Here the changed gist:
https://gist.github.com/ManuelTS/935155f423374e950566d05d1448038d

@JhonattaSantos

This comment has been minimized.

JhonattaSantos commented Nov 22, 2017

Thanks a lot!

@empeje-mid

This comment has been minimized.

empeje-mid commented Nov 27, 2017

Thank a lot!

I do some modification from your script for dockerizing purpose

https://gist.github.com/mappuj1/31e6dea39d48d56c74ead82177fd0523

@akilawickey

This comment has been minimized.

akilawickey commented Mar 27, 2018

Cool Thanks

@b3none

This comment has been minimized.

b3none commented Jun 7, 2018

You saved me!

@iamvinny

This comment has been minimized.

iamvinny commented Jun 15, 2018

Why the fixed version though? PhantomJS has been updated, the currently version is 2.1.1.

@julesmqz

This comment has been minimized.

julesmqz commented Sep 2, 2018

Thank you very much. working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment