1. 确认VNC是否安装
$ rpm -q vnc vnc-server
2. 编辑配置文件
$ vim /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# URL:http://www.uk.research.att.com/vnc/sshvnc.html
VNCSERVERS="1:username"
3. 创建vnc password
$ vncpasswd
4. 编辑xstartup
$ vim ~/.vnc/ xstartup
将这两行前面的注释符号“#”去掉
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
5. 打开端口5901,重启iptables服务
$ vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
$ service iptables restart
6. 更改/etc/hosts
为了避免xauth:(stdin):1:bad display name " " in "add " command的错误,在/etc/hosts中加入主机名,或者到System->Administration->Network中的DNS选项里加入主机名。
主机名可以用uname -a 获得。
7. 启动vncserver
$ service vncserver start