So I was writing some scripts for my automated web functional testing using PHPUnit and I encountered an error that prevented me from opening the Firefox browser from the server.
When I tried to run my PHPUnit script, I was bothered by this error:
Error: no display specified
I tried running “firefox” on my CentOS CLI and it gave me the same error message. So I found out that my script is trying to run Firefox within the server but the GUI should pop up on the client side.
Apparently, I need to configure some stuff before I’d able to do this.
Problem: I needed to run Firefox from a Linux server remotely and display the GUI locally in my Windows client.
WHAT’S IN MY MACHINE: Assumptions
- CentOS Linux
- PHP 5.4.4
- Yii 1.1.12
WHAT TO DO: Installations
Your server must have the following installed:
- Firefox (if not installed, just run this: yum install firefox)
- X Windows System (if not installed, just run this: yum groupinstall X Window System)
In your client (Windows 7), install the following:
Putty – for the SSH client
Xserver – to display X11 applications
- Putty http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Xserver (XMing) – http://sourceforge.net/projects/xming/
The installation procedure is pretty straightforward so I won’t write it here anymore.
THE TRICKY PART: Configuration
Once you’ve installed the applications, do the following:
1. Double click on the Xming shortcut on your desktop. Your X Server is now running.
2. Click Putty.
3. In Sessions tab, fill in the details:
Host Name (or IP address) – you should put here the IP address of your server
Port – 22
Connection Type: SSH
4. Expand the Connection tab and find and click the SSH branch.
Check the “Enable X11 forwarding”
Check the MIT-Magic-Cookie-1
5. Go back to Session branch and Save it and then click Open.
6. Log in using your account details and try running “firefox”. It should be working by now.
Thus, your PHPUnit functional tests should be able to run using Firefox as well.
Generally speaking, you should now be able to run X applications from the server on your local desktop.
Also, make sure that the following are set to “yes” in your server’s /etc/ssh/sshd_config