Install tightVNC on Ubuntu server
1. Make sure Ubuntu desktop is ready
2. Install tightvnc server
$ sudo apt-get install tightvncserver
3. Test vnc client
Launch tightvnc or ultravnc viewer, and input server as “192.168.1.101:1”
4. Start up applications with vnc client log in
Put all application start up commands in ~/.vnc/xstartup.
5. Create a booting script
$ sudo vi /etc/init.d/vncserver
———————– vncserver begin —————————
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: 3 4 5
# Default-Stop: 0 6
### END INIT INFO
PATH=”$PATH:/usr/X11R6/bin/”# The Username:Group that will run VNCexport USER=”vncuser” # The user to start vnc
#${RUNAS}# The display that VNC will use
DISPLAY=”1″ # user display number 1
# Color depth (between 8 and 32)
DEPTH=”16″
# The Desktop geometry to use.
#GEOMETRY=”<WIDTH>x<HEIGHT>”
#GEOMETRY=”800×600″
GEOMETRY=”1024×768″
#GEOMETRY=”1280×1024″
# The name that the VNC Desktop will have.
NAME=”vnc-server”
OPTIONS=”-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}”
. /lib/lsb/init-functions
case “$1” in
start)
log_action_begin_msg “Starting vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver ${OPTIONS}”
;;
stop)
log_action_begin_msg “Stoping vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver -kill :${DISPLAY}”
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
———————– vncserver end ———————
6. Change the script to excutable
$ sudo chmod +x vncserver
7. Set up vncserver auto start and stop with system start up and shutdown
$ sudo update-rc.d vncserver defaults
# change the “defaults” to ” defaults 99″ if want it run or stop as the last script
eg.
$ sudo update-rc.d vncserver -f remove
$ sudo update-rc.d vncserver defaults 99
Install VNC on Ubuntu server
In order to remote log in via the graphic desk to Ubuntu server, a installation of VNC is needed. Following demonstrate the detailed steps for VNC setting on Unbuntu.
1. Make sure Gnome or other x-window is ready on Ubuntu
2. Install VNC server on Ubuntu
$ sudo apt-get install vnc4server
3. Set up a VNC password for current user, this password is needed while connect VNC client
$ vncpasswd
4. Set up a display number
$ vncserver :1
This would create necessary files for VNC server.
VNC clinet log in need to input “192.168.1.100:1”. The number “1” is the display number.
5. Set up Gnome for VNC log in
5.1 Shutdown VNC server
$ vncserver -kill :1
5.2 Set up xstartup file for current user
$ cd
$ cd .vnc
$ vi xstartup
——- xstartup ———
#!/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 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” & # comment this line
# x-window-manager & # comment this line
gnome-session & # add this line, for gnome only
———————- xstartup ——————
5.3 Restart vncserver
$ vncserver :1
6. vnc client log in error
Failed to load session “Ubuntu”
This message is because the problem of desktop installation. Use “apt-get install ubuntu-desktop” to reinstall the graphic desktop.