Gui on a Headless VPS
If you wish to run a gui application on a virtual private server (vps) you have two choices.
The first one doesn't count - it's painful. That's running X with a virtual frame buffer for the display. Something like Xvfb. It's just too slow. It is also fairly resource heavy.
The better bet is to use a vnc server such as tigervnc-server on the VPS and a vnc client on your local system.
You will want to install a very light weight desktop such as fluxbox, a terminal, and whatever gui app that you really want to run, in my case it was firefox. You can install a full desktop environment if you like but I really only wanted to be able to run firefox.
On the vps as root…
pkg install tigervnc-server fluxbox xfce4-terminal firefox
As your user on the vps…
cd ~ mkdir .vnc cd .vnc vncpasswd passwd echo "geometry=1900x1000" > config echo "localhost" >> config echo "AlwaysShared" >> config echo "#!/bin/sh" > xstartup echo "exec fluxbox" >> xstartup chmod u+x xstartup
Now you should be ready to go if you have a local vnc client all setup. I would recommend tigervnc just to keep things consistent.
From you local client
# we will tunnel the vnc connection through ssh ssh -L 5901:localhost:5901 user@vps # after you connect run vncserver # -autokill will shutdown vnc after xstartup finishes (usually) vncserver -autokill
You will get a message about it running the xstartup script we created and where the log file is located.
Now with your local vnc client you should be able to connect to localhost:5901. You will be prompted for the password you configured above.
If you don't like the default fluxbox menu you can change it in ~/.fluxbox/menu and reload the config.
And off you go.