How to install and run PhantomJS in Ubuntu Oneiric 11.10

Ubuntu 11.10 have several updates and seems it might have problem with PhantomJS. But don't worry, i will show you the way to install and run PhantomJS without problem here.

1. Install dependency

sudo apt-get install xvfb git build-essential gtk2-engines-pixbuf xfonts-100dpi x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
sudo apt-get install libqt4-dev libqtwebkit-dev qt4-qmake python-qt4


2. Install PhantomJS

cd ~/
git clone git://github.com/ariya/phantomjs.git && cd phantomjs
qmake-qt4 && make
sudo cp bin/phantomjs /usr/local/bin/


3. Testing PhantomJS
Create this website screenshots :

DISPLAY=:0 phantomjs ~/phantomjs/examples/rasterize.js http://yoodey.com screenshot.png


You should follow me here

Comments

Hi
I followed the instruction and on qmake-qt4 && make command it showed the usage for qmake-qt4:

Usage: qmake-qt4 [mode] [options] [files]
QMake has two modes, one mode for generating project files based on
some heuristics, and the other for generating makefiles. Normally you
shouldn't need to specify a mode, as makefile generation is the default
mode for qmake, but you may use this to test qmake on an existing project
...

So it actually not run the process. How to fix it?

Make sure you already in phantomjs folder before doing that.
"cd phantomjs"

Thanks!, this works nicely for ubuntu 12.04 Beta 64bit, just finished doing it just now.

Hello, I follow the steps on my ubuntu 11.10, 32bit computer and have some problem:

cd src/ && make -f Makefile.phantomjs
make[1]: Entering directory `/home/sunyayuan/phantomjs/src'
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG_OUTPUT -DQT_NO_WARNING_OUTPUT -DHAVE_CONFIG_H -DHAVE_FCNTL_H -DHAVE_STDARG_H -DHAVE_STDINT_H -DHAVE_UNISTD_H -DUSE_UTF8 -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtWebKit -I/usr/include/qt4 -Igif -Imongoose -Ilinenoise/src -I. -o phantom.o phantom.cpp
In file included from phantom.cpp:42:0:
webpage.h:120:26: error: ‘JavaScriptError’ in ‘class QWebPage’ does not name a type
webpage.h:120:53: error: ISO C++ forbids declaration of ‘error’ with no type [-fpermissive]
phantom.cpp: In member function ‘void Phantom::onInitialized()’:
phantom.cpp:304:5: error: no matching function for call to ‘QWebFrame::evaluateJavaScript(QString, QString)’
phantom.cpp:304:5: note: candidate is:
/usr/include/qt4/QtWebKit/qwebframe.h:203:14: note: QVariant QWebFrame::evaluateJavaScript(const QString&)
/usr/include/qt4/QtWebKit/qwebframe.h:203:14: note: candidate expects 1 argument, 2 provided
make[1]: *** [phantom.o] Error 1
make[1]: Leaving directory `/home/sunyayuan/phantomjs/src'
make: *** [sub-src-phantomjs-pro-make_default-ordered] Error 2

I Google it and install libxft-dev on my computer but it still report error.

Add new comment