$ su -
# apt-get update; apt-get dist-upgrade -y --force-yes
1、Install GUI on Ubuntu 14.04 Server
apt-get install gnome-core xfce4 firefox nano -y --force-yes
或者
apt-get install xubuntu-desktop xfce4 firefox nano -y --force-yes
2、Install VNC Server on Ubuntu 14.04
apt-get install vnc4server -y --force-yes
3、Configure VNC Server to work on Ubuntu 14.04
adduser vncuser
passwd vncuser
转换到你要登陆的VNC SERVER的用户下:
su - vncuser
启动VNC server:
vncserver
kill VNC Server session:
vncserver -kill :1
modify xstartup file:
cd ~
> .vnc/xstartup
nano .vnc/xstartup
输入内容为:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
create VNC Server statup script:
su -
nano /etc/init.d/vncserver
内容为:
#!/bin/bash
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: vnc server
# Description: http://www.namhuy.net
#
### 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
设置可执行权限:
chmod +x /etc/init.d/vncserver
mkdir -p /etc/vncserver
nano /etc/vncserver/vncservers.conf
VNCSERVERS="1:vncuser"
VNCSERVERARGS[1]="-geometry 1024x768"
update-rc.d vncserver defaults 99
reboot