CentOS系統(tǒng)中VNC配置
在CentOS系統(tǒng)安裝的時(shí)候,我們應(yīng)該對(duì)VNC做好配置,所以,在這里,我們來簡(jiǎn)單的學(xué)習(xí)一下如何在CentOS系統(tǒng)中進(jìn)行VNC配置。
1.檢查VNC客戶端和服務(wù)器端是否已經(jīng)安裝
執(zhí)行如下命令:
rpm -q vnc vnc-server
假如返回類似如下信息,
package vnc is not installed
vnc-server-4.0-8.1
則說明系統(tǒng)已經(jīng)默認(rèn)安裝了vnc服務(wù)器端(一般來說,CentOS系統(tǒng)都默認(rèn)安裝了vnc server)。
2. 在CentOS系統(tǒng)中將用戶名加入到配置文件中
使用如下命令編輯配置文件,添加帳戶信息:
vi /etc/sysconfig/vncservers
做如下修改
- #
- # 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
- # lt;URL:http://www.uk.research.att.com/vnc/sshvnc.htmlamp;gt;.
- # VNCSERVERS="1:myusername"
- # VNCSERVERS="1:gavin 2:john" # use the method for more user
- VNCSERVERS="2:root"
- # VNCSERVERARGS[1]="-geometry 800x600"
- VNCSERVERARGS[2]="-geometry 1024x768"
3.設(shè)置 root用戶的密碼
使用如下命令設(shè)置密碼:vncpasswd
當(dāng)提示Verify時(shí),再次輸入密碼確認(rèn)。
4.啟動(dòng)VNC服務(wù)
使用如下命令啟動(dòng)VNC SERVER
sbin/service vncserver start
當(dāng)顯示如下信息時(shí),表示啟動(dòng)成功:
Starting VNC server: 2:root [ OK ]
5.修改VNC SERVER的窗口治理器
vnc server默認(rèn)使用的窗口治理器是twn,這是一個(gè)非常簡(jiǎn)單的窗口治理器,我們可以改成常用的GNOME或者KDE。
先使用如下命令進(jìn)入用戶的home目錄:cd "/.vnc
編輯啟動(dòng)項(xiàng):vi xstartup
按照如下方式修改啟動(dòng)項(xiàng):#!/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"
- gnome-session #以GNOME作為VNC的窗口治理器
- #startkde #kde desktop
#twm #注掉CentOS系統(tǒng)默認(rèn)的窗口治理器
6.重啟VNC SERVER
/sbin/service vncserver restart
當(dāng)CentOS系統(tǒng)提示如下信息時(shí),表示重啟成功:
Shutting down VNC server: 2:root [ OK ]
Starting VNC server: 2:root [ OK ]
7、從VNC view登錄
在windows上安裝vnc view,然后輸入xxx.xxx.xxx.xxx:2,連接登錄,輸入密碼即可。備注:假如從vnc view登錄時(shí),提示connection refused(10061),則是因?yàn)閘inux防火墻的問題,登錄centos系統(tǒng),選擇SystemPreferencesRemote Desktop,勾選sharing中的兩項(xiàng),Security兩項(xiàng)不勾,點(diǎn)擊關(guān)閉,然后再重新用vnc view登錄即可。
【編輯推薦】