为了节省系统资源,VNC这个服务一般是不开启的,但是偶尔还是用得着。
一、安装vncserver
yum -y install vnc*二、配置vncserver ,参考如下配置文件
[root@localhost ~]# cat /etc/sysconfig/vncservers # 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 # <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>. # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP. # Use "-nohttpd" to prevent web-based VNC clients connecting. # 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:myusername" # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 1024x768"三、设置vnc 密码
[root@localhost ~]# vncpasswd Password: Verify: [root@localhost ~]#四 、启动vncserver
[root@localhost ~]# service vncserver stop 关闭 VNC 服务器:1:root [确定] [root@localhost ~]# service vncserver start 启动 VNC 服务器:1:root New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/localhost.localdomain:1.log [确定] [root@localhost ~]#五、关于桌面的配置文件
[root@localhost ~]# cat /root/.vnc/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 & #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #twm & gnome-session & [root@localhost ~]#六、访问方式
1、网页连接 用IE打开 :5801/ 特别注意:用IE
2、使用 VNC Viewer 4 ,本文后有附件,可以下载。连接时填写参数如:
192.168.xx.xxx:1
七、关于多用户
其实个人并不建议VNC保持长期开启,只作为临时需要使用的时候开启服务,但是我仍然给出相关方法。