How can I run Firefox on Linux headlessly (i.e. without requiring libgtk-x11-2.0.so.0)?
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 &
I know this is a rather old question, but I wanted to add a more recent answer as I got directed here by Google and had to search for a while to find the answer.
As of Firefox 57, you can run in headless mode simply by installing Firefox and running:
firefox -headless http://test.com/
See the Firefox dev docs here.
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.
Even in the Firefox headless version, GTK+ is still needed.