Screenshots using Firefox and Xvfb in Amazon EC2

Running a screenshot server in Amazon linux can be little tricky in EC2 but not impossible. I managed to install headless server Xvfb, Firefox in Amazon EC2 and it worked great. I wrote a quick shell script to capture screenshots from list of URLs stored in a file. I have to admit that compiling Xvfb, GTK+, Firefox in Amazon EC2 platform is a bit challenging.

aws

You can see the script Github: https://github.com/olddocks/Xvfb-screenshots

Installation

First prepare your amazon server with necessary libraries

sudo yum groupinstall "Development Tools"
yum install imagemagick

Then you have to install GTK+, Firefox using script https://gist.github.com/joekiller/4144838

chmod +x gtk-firefox.sh
./gtk-firefox.sh

This will take about 15-20 minutes to compile and install all libraries. Then install Xvfb server and necessary fonts and in Amazon linux. I found out the fonts needed to render are located in /usr/share/X11/fonts/misc

yum install xorg-x11-server-Xvfb xorg-x11-fonts

If all is good then, go ahead and launch the script.

./screenshot.sh urls.txt

You should have list of URLs in a text file in a separate file line by line

This will launch the Xvfb server display 0 with resolution 1280×1024. You might see some warnings of fonts when Xvfb is running, just ignore them.

Xvfb -fp /usr/share/X11/fonts/misc :0 -screen 0 1280x1024x24& 

A sample screenshot is below..

image2