This guide uses Ubuntu version 12.04 LTS so there may be extra steps for different versions. Recommended VPS specifications: Our “Minimal” plan.
Update your repository source file
This is a very simple action. Just edit the sources.list file:
nano /etc/apt/sources.list
Delete everything inside and paste this:
deb http://ubuntu-archive.mirror.serveriai.lt/ precise main restricted universe deb http://ubuntu-archive.mirror.serveriai.lt/ precise-updates main restricted universe deb http://ubuntu-archive.mirror.serveriai.lt/ precise-security main restricted universe multiverse deb http://archive.canonical.com/ubuntu precise partner
Save and proceed to the next step.
Installing the GNOME environment
Using apt-get, first, update your system packages to the latest versions before we proceed:
apt-get update apt-get upgrade
Use apt-get to install GNOME and necessary font packages:
apt-get install gnome-core xfonts-100dpi xfonts-100dpi-transcoded xfonts-75dpi xfonts-75dpi-transcoded xfonts-base
Remove NetworkManager as this will overwrite our local name server settings and cause you to be unable to resolve domains:
apt-get remove network-manager
Installing and Configuring vnc4server
Using apt-get install vnc4server:
apt-get install vnc4server
Now we need to add a user that the desktop will be running under as well as create a password for that user. Please choose a strong password of minimum 8 characters in length using uppercase, lowercase, numbers and symbols:
adduser vncuser
After adding the user, we will need to create and edit the VNC server configuration to specify which user will be able to connect as well as what screen resolution they will use. You can change the screen resolution to any value. Common values are 1024×768, 1680×1050, and 1920×1080. You may want to reduce these values slightly less than your local PC’s screen resolution (Example: if using 1920×1080 at home, try setting your VNC resolution to 1900×960):
mkdir -p /etc/vncserver touch /etc/vncserver/vncservers.conf nano /etc/vncserver/vncservers.conf
Add the following lines to the file:
VNCSERVERS="1:vncuser" VNCSERVERARGS[1]="-geometry 1024x768"
Since we’ll want the VNC server to start on boot, we’ll need to create a service for it. In the next steps, we’ll be creating a service script for this purpose. Simply copy and paste the code below into the file:
touch /etc/init.d/vncserver chmod +x /etc/init.d/vncserver nano /etc/init.d/vncserver
Contents of /etc/init.d/vncserver:
unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Shutting down VNCServer: "
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
export USER="${display##*:}"
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
fi
done
echo -e "\n"
echo "VNCServer Stopped"
}
case "$1" in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
Register the service:
update-rc.d vncserver defaults 99
Now we must create a VNC connection password for our user. First, we will use the su command to log in to the user’s shell and use the vncpasswd to set the password:
su vncuser vncpasswd
We need to start then stop the server to generate a configuration file:
vncserver :1; vncserver -kill :1
After we’ve generated the configuration file, we must edit it so that GNOME is loaded
when we connect:
nano ~/.vnc/xstartup
Edit the file or replace its contents so that they look like the code below and save:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
gnome-session --session=gnome-classic &
[ -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" &
# x-window-manager &
Drop back to root shell:
exit
Start the VNC service:
service vncserver start
Connecting to your VNC server from your local PC
To connect to your newly operational server, you will need a VNC client. We recommend TigerVNC:
TigerVNC Client for Windows: http://sourceforge.net/projects/tigervnc/files/latest/download
When connecting using this software, you will need to specify the port for connecting. If using the configuration above, this port will be 1. In the server field of the client, you can enter the port like this Your_server_IP:1