首先讲述一下vnc的机制:
Linux下的VNC可以同时启动多个vncserver,各个vncserver之间用显示编号(display number)来区分,每个vncserver服务监听3个端口,它们分别是:
5800+显示编号: VNC的httpd监听端口,如果VNC客户端为IE,Firefox等非vncviewer时必须开放
5900+显示编号: VNC服务端与客户端通信的真正端口,必须无条件开放
6000+显示编号: X监听端口,可选显示编号、开放的端口分别由/etc/sysconfig/vncservers文件中的VNCSERVERS和VNCSERVERARGS控制。
-geometry 桌面分辨率,默认1024x768;
-nohttpd 不监听HTTP端口(58xx端口);
-nolisten tcp 不监听X端口(60xx端口);
-localhost 只允许从本机访问;
-AlwaysShared 默认只同时允许一个vncviewer连接,此参数允许同时连多个vncviewer;
-SecurityTypes None 登录不需要密码认证VncAuth默认值,要密码认证。
1、首先确认系统上有没有vnc,vnc-server
rpm -qa | grep 'vnc'
否则安装之
yum install vnc vnc-server
2、配置/etc/sysconfig/vncserver
[plain] view plain copy print ?
- # The VNCSERVERS variable is a list of display:user pairs.
- #
- # Uncomment the lines below to start a VNC server on display :2
- # 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 this URL:
- # http://kbase.redhat.com/faq/docs/DOC-7028
- # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
- # Use "-localhost" to prevent remote VNC clients connecting except when
- # doing so through a secure tunnel. See the "-via" option in the
- # `man vncviewer' manual page.
- VNCSERVERS="2:cshi"
- VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
即uncomment最后二行,并改成实际的用户名
重启VNC服务:

3、安装libXfont和pixman等
若此时执行vncserver,则会有如下报错:
[plain] view plain copy print ?
- vncext: VNC extension running!
- vncext: Listening for VNC connections on all interface(s), port 5902
- vncext: created VNC server for screen 0
- [dix] Could not init font path element /usr/share/X11/fonts/misc, removing from list!
- [dix] Could not init font path element /usr/share/X11/fonts/100dpi, removing from list!
- [dix] Could not init font path element /usr/share/X11/fonts/Type1, removing from list!
- [dix] Could not init font path element /usr/share/fonts/default/Type1, removing from list!
- [dix] Could not init font path element built-ins, removing from list!
- Fatal server error:
- could not open default font 'fixed'
经调查得知:yum install libXfont可解决之
再执行vncserver,又有如下错误:
[plain] view plain copy print ?
- /usr/bin/Xvnc: symbol lookup error: /usr/bin/Xvnc: undefined symbol: pixman_composite_trapezoids
- /usr/bin/Xvnc: symbol lookup error: /usr/bin/Xvnc: undefined symbol: pixman_composite_trapezoids
解决办法:yum install pixman
4、准备登陆
用vncviewer客户端进行登陆。如果没有指定Xvnc的显示号,则
指定显示号后:
若系统中安装了智能卡软件,则会有如下反应,可不管:
或者停止该服务:service pcscd stop