Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I’ve got Dreamhost shared hosting, and I’m trying to run Firefox 3.0 on it headlessly for use with Selenium.

When I try to run it (~/local/bin/firefox/firefox), I get the following error message:

error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

How can I run Firefox on Linux without requiring this shared object file?

share|improve this question
up vote 9 down vote accepted

You can't run Firefox without all the Gtk libraries it requires, but that's easily solved by installing the libraries. Normally you would install Firefox through a package management system and this would pull in all the required libraries.

To run Firefox normally, you need an X server (that's the part that displays the windows and their contents, as opposed to things like Gtk which are libraries that the applicattion uses to build the content). That's something you wouldn't usually run on a server. There are a very few things you can do in Firefox without an X server, I don't know if Selenium is one of them.

To run Firefox on your server, run a “virtual” X server. A simple one is Xvfb (virtual framebuffer X server). It's in the X.org server distribution. Sample usage:

Xvfb :19 -screen 0 1024x768x16 &
export DISPLAY=:19
firefox &
share|improve this answer
Excellent, cheers Gilles, that’s done it. I also found these articles helpful for getting Xvfb running: alittlemadness.com/2008/03/05/running-selenium-headless, and blog.kabisa.nl/2010/05/24/… – Paul D. Waite Mar 14 '11 at 8:44

You can't; it is linked with the X and Gtk+ client libraries, and I don't think it's even possible to build it without them.

share|improve this answer

Since Selenium is a GUI testing tool, I would find it hard to believe that it can work without X.

So my best guess is that your headless server requires an X installation such as that suggested by Gilles. There are a number of similar alternatives.

share|improve this answer

You can

  • use a Firefox in a virtual framebuffer: xvfb -a firefox
  • use PhantomJS as embedded WebKit without the need for a display and selenium support via GhostDriver - if WebKit is OK for you.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.