一、安装vncserver

  1. yum -y install vnc*

二、配置vncserver ,参考如下配置文件

  1. [root@localhost ~]# cat /etc/sysconfig/vncservers

  2. # The VNCSERVERS variable is a list of display:user pairs.

  3. #

  4. # Uncomment the lines below to start a VNC server on display :2

  5. # as my 'myusername' (adjust this to your own).  You will also

  6. # need to set a VNC password; run 'man vncpasswd' to see how

  7. # to do that.  

  8. #

  9. # DO NOT RUN THIS SERVICE if your local area network is

  10. # untrusted!  For a secure way of using VNC, see

  11. # <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.

  12. # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

  13. # Use "-nohttpd" to prevent web-based VNC clients connecting.

  14. # Use "-localhost" to prevent remote VNC clients connecting except when

  15. # doing so through a secure tunnel.  See the "-via" option in the

  16. # `man vncviewer' manual page.

  17. # VNCSERVERS="2:myusername"

  18. # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

  19. VNCSERVERS="1:root"

  20. VNCSERVERARGS[1]="-geometry 1024x768"

三、设置vnc 密码

  1. [root@localhost ~]# vncpasswd

  2. Password:

  3. Verify:

  4. [root@localhost ~]#  

四 、启动vncserver

  1. [root@localhost ~]# service vncserver stop

  2. 关闭 VNC 服务器:1:root [确定]

  3. [root@localhost ~]# service vncserver start

  4. 启动 VNC 服务器:1:root  

  5. New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

  6. Starting applications specified in /root/.vnc/xstartup

  7. Log file is /root/.vnc/localhost.localdomain:1.log

  8. [确定]

  9. [root@localhost ~]#  

五、关于桌面的配置文件

  1. [root@localhost ~]# cat /root/.vnc/xstartup

  2. #!/bin/sh

  3. # Uncomment the following two lines for normal desktop:

  4. # unset SESSION_MANAGER

  5. # exec /etc/X11/xinit/xinitrc

  6. [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

  7. [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

  8. xsetroot -solid grey

  9. vncconfig -iconic &

  10. #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

  11. #twm &

  12. gnome-session &

  13. [root@localhost ~]#  

六、访问方式

1、网页连接 用IE打开 http://192.168.xxx.xxx:5801/  特别注意:用IE

2、使用 VNC Viewer 4 ,本文后有附件,可以下载。连接时填写参数如:

   192.168.xx.xxx:1

七、关于多用户

  其实个人并不建议VNC保持长期开启,只作为临时需要使用的时候开启服务,但是我仍然给出相关方法。

编辑 /etc/sysconfig/vncserver

  1. VNCSERVERS="1:root 2:user01"

  2. VNCSERVERARGS[1]="-geometry 1024x768"

  3. VNCSERVERARGS[2]="-geometry 1024x768"

八、一些命令

1、kill当前某个vnc帐户

  1. vncserver -kill :1

2、启动某个vnc帐户

  1. vncserver :1

3、关闭、启动、重启 vnc服务

  1. service vncserver stop

  2. service vncserver start

  3. service vncserver restart

九、一些错误

1、你可能同时开启了ssh和vnc等终端服务,vnc连接后服务器可能会提示

“我检测到已有一个面板在运行,现在将退出”的对话框,另外你可能还发现系统桌面上的菜单栏点不了或跟本看不见。

解决方法:

  1. [root@localhost ~]# cat /etc/inittab  

  2. #

  3. # inittab       This file describes how the INIT process should set up

  4. #               the system in a certain run-level.

  5. #

  6. # Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>

  7. #               Modified for RHS Linux by Marc Ewing and Donnie Barnes

  8. #

  9. # Default runlevel. The runlevels used by RHS are:

  10. #   0 - halt (Do NOT set initdefault to this)

  11. #   1 - Single user mode

  12. #   2 - Multiuser, without NFS (The same as 3, if you do not have networking)

  13. #   3 - Full multiuser mode

  14. #   4 - unused

  15. #   5 - X11

  16. #   6 - reboot (Do NOT set initdefault to this)

  17. #  

  18. #id:5:initdefault:

  19. id:3:initdefault:

更改系统的运行模式为多用户,将 id:5:initdefault:  改成 id:3:initdefault: