Even on a low RAM vps you are able to run a desktop environment.
If you do have a lot of free RAM you can even run desktop apps and IDEs like Eclipse on your vps.
I use my KVM vps to have a portable and accessable Ruby and Java development environment.
One of the desktop managers that do have a small footprint is xfce4. So this tutorial is based on that peace of software.
1. Install xfce and a browser (I take iceweasel - well Firefox - due to the Debian Free Software Guidelines)
sudo apt-get install xfce4 xfce4-clipman xfce4-goodies vnc4server iceweasel
2. Configure vnc4server
First of all run vnc4server to generate the configs and to setup the password:
Type in your password twice and kill the vnc instance:
vncserver -kill :1
Vnc is about virtual displays. Like any x-based system it counts the displays. So “:1” stands for the first display.
Now we change the x windows manager to xfc4:
Exchange “x-window-manager” with “startxfce4”:
#!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & startxfce4 &
3. Run it
You can start the vnc instance with following command:
vnc4server :1 -geometry 1280x960 -depth 16 -screen scrn 1280x960x16 &
We use “&” to background the process.
Some words to the parameters (manpage):
-geometry widthxheight Specify the size of the desktop to be created. Default is 1024x768. -depth depth Specify the pixel depth in bits of the desktop to be created. Default is 16, other possible values are 8, 15 and 24 - anything else is likely to cause strange behaviour by applications.
So why the “-screen” parameter?
Well to do everything twice - or (better idea) to keep my scripts compatible to the package vncserver.
4. Keep it running
One thing that annoys me about this way to startup the vnc server is that it does not survive restarts.
One dirty simple way is to use rc.local
sudo nano /etc/rc.local
With following content:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. vncserver -kill :1 su - wlanboy -c "cd /home/wlanboy && vnc4server :1 -geometry 1280x960 -depth 16 -screen scrn 1280x960x16" 2>/dev/null & exit 0
So what do we do?
- Stop a allready running vncserver instance on disply 1
- Run a given command (-c) using the user “wlanboy”
- The command itself switches to the home direcoty and runs the vnc4server command
You can copy the commands to start additional vnc instances.
Just double check that you alter the display numbers.
Please deactivate the screen saver because most of them are quite cpu consuming.
Things to change if you want to run openbox:
1. Install openbox
apt-get install openbox obconf obmenu menu conky nitrogen
So what are we installing?
- openbox - the GUI itself
- obconf - the configuration manager of openbox
- obmenu - well the menu (right click) of openbox
- conky - a nice system monitor
- nitrogen - a lightweight desktop background browser
- tint2 - a lightweight window manager for openbox
2. Change vnc config
#!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & openbox-session &
Just the last line has to be modified.