How can I run Firefox on CentOS with no display? [closed]
I'm trying to run Firefox GUI browser on headless CentOS server in order to perform some web testing.
I don't need to see the graphical output, because i use Selenium server API to control browser's input and inspect the output.
The setup was successfully tested on desktop Mac computer. It, however, fails to run on my headless VPS CentOS server with following message "Error: no display specified." (Which makes sense, since it's just a server sitting on a rack someplace.)
How can I get Firefox to run without a display, so Selenium will be able to interact with it? Or - more broadly - how do people run GUI-only applications on a Linux server when there is no display?
I've noticed that Firefox has this command line option:
X11 options
--display=DISPLAY X display to use
Unfortunately I don't know anything about X11 or displays under CentOS so I don't know what to specify on the command line, or if this would help.
Use Xvfb. It gives you an X server that doesn't require connection to a physical display.
(So, on CentOS, you'd do something like "yum install xorg-x11-server-Xvfb".)
You can then start it up on display ":1" with the command "/path/on/which/installed/Xvfb :1 -screen 0 1024x768x24 &". This will create a screen with resolution 1027x768 and depth 24. Use of "&" will make the command execute in the background.
Before launching Firefox, you need to make the display accessible, which is done using the Export command - ie. "export DISPLAY=:1", pointing to whatever host is appropriate.