其实其它linux平台也差不多。 VNC client software (tightVNC, you can download it here.) RHEL下默认有了Xvnc,只是服务没有启动,免安装。 下面启动vnc服务: # service vncserver start Starting VNC server: [ OK ] # vncpasswd Password: Verify: # vncserver New 'roswell:1 (root)' desktop is roswell:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/roswell:1.log 此时可以通过vnc客户端软件(端口默认5901)或浏览器(端口默认5801,如 http://192.168.0.1:5801 ) 登陆,输入刚才设置的密码。 此时默认不是gnome或kde界面,如果不想使用默认的twm,还有修改用户主目录下.vnc目录里的xstartup (注意这个文件是在vnc client登陆后自动生成的): # cd ~/.vnc# vi 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" & startx & 然后再重启vncserver即可,目前都是以root身份登陆的,太危险了。 需要设置具体登陆的用户和分辨率,可以修改/etc/sysconfig/vncservers文件: # vi /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:oracle" VNCSERVERARGS[1]="-geometry 1024x768" /etc/sysconfig/vncserver要这样设置: 为每个你允许使用vnc的用户添加两行 VNCSERVERS="x:username" VNCSERVERARGS[x]="-geometry 800x600 -query localhost" 这里,第一行中x>0,5800+x和5900+x分别是vnc监听的端口,前者是使用http协议的,第二行是设置该用户vnc进程的参数。 例如: VNCSERVERS="3:foo" VNCSERVERARGS[3]="-geometry 800x600 -query localhost" 表示用户foo可以通过 http://serverip:5803/ 或用vnc viewer连接serverip:5903 来访问。 最后,要为每个使用vnc的用户用vncpasswd命令设置访问口令。 重启vncserver: # service vncserver status Xvnc (pid 5718) is running... # service vncserver restart Shutting down VNC server: [ OK ] Starting VNC server: [ OK ] # service vncserver status Xvnc (pid 5718) is running... # kill 5718 # kill 5718 -bash: kill: (5718) - No such process # service vncserver start Starting VNC server: 1:oracle [ OK ] # service vncserver status Xvnc (pid 7679) is running... # refer: http://skullbox.net/vncserver.php http://www.lslnet.com/linux/dosc1/60/linux-396057.htm --End-- 5.1版本除了以上设置外,可能会遇到如下情况: [root@localhost ~]# /etc/init.d/vncserver start 启动 VNC 服务器:no displays configured [确定] [root@localhost ~]# /etc/init.d/vncserver status Xvnc 已停 [root@localhost ~]# 以服务的方式为什么不能启动??? 这样就正常. 不想每次都 telnet上去启vncserver ------------ [root@localhost ~]# vncserver 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 ~]# /etc/init.d/vncserver status Xvnc (pid 2935) 正在运行... [root@localhost ~]# 解决办法:只要把/etc/sysconfig/vncservers最好两行的注释去掉,并编辑一下即可。 (责任编辑:IT) |