This guide uses Ubuntu version 12.04 LTS so there may be extra steps for different versions. Recommended VPS specifications: Our "Minimal" plan.
1. Update Your Repository Source File
First, modify your repository source list to use a reliable mirror:
sudo nano /etc/apt/sources.list
Remove existing entries and add the following:
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 exit the file.
2. Install GNOME
Update your package list and upgrade your system:
sudo apt-get update
sudo apt-get upgrade
Install GNOME and necessary font packages:
sudo apt-get install gnome-core xfonts-100dpi xfonts-100dpi-transcoded xfonts-75dpi xfonts-75dpi-transcoded xfonts-base
Remove NetworkManager to avoid conflicts with local name server settings:
sudo apt-get remove network-manager
3. Install and Configure VNC Server
Install VNC server:
sudo apt-get install vnc4server
Create a new user for VNC sessions and set a strong password:
sudo adduser vncuser
Create and edit the VNC server configuration:
sudo mkdir -p /etc/vncserver
sudo touch /etc/vncserver/vncservers.conf
sudo nano /etc/vncserver/vncservers.conf
Add the following lines, adjusting the screen resolution as needed:
VNCSERVERS="1:vncuser"
VNCSERVERARGS[1]="-geometry 1024x768"
4. Create a VNC Server Service Script
Create and edit a new service script for VNC:
sudo touch /etc/init.d/vncserver
sudo chmod +x /etc/init.d/vncserver
sudo nano /etc/init.d/vncserver
Add the following content to the script:
#!/bin/bash
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: vnc server
# Description:
#
### END INIT INFO
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 to start at boot:
sudo update-rc.d vncserver defaults 99
5. Set Up VNC Password and Configuration
Switch to the VNC user and set up the VNC password:
su vncuser
vncpasswd
Start and stop the VNC server to generate a configuration file:
vncserver :1
vncserver -kill :1
Edit the VNC configuration file to load GNOME:
nano ~/.vnc/xstartup
Replace its contents with:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
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" &
Exit the VNC user shell:
exit
Start the VNC service:
sudo service vncserver start
6. Connect to Your VNC Server
To connect, use a VNC client such as TigerVNC. Specify the server’s IP and port (e.g., Your_server_IP:1
).