woff 發表於 2011-4-7 13:27:10

Linux.CentOS 下VNCServer安裝與設定

步驟1.修改 vncserver 設定檔
在修改前我們先確定系統是否有安裝 VNC Server 套件。rpm -q vnc vnc-server vnc-server-4.1.2-9.el5修改 vnc server 設定檔,只加入如下一行即可而 100 的意思為屆時連接 VNC Service 時的 Port (5900 + 100),所以設定 100 到時連接 VNC Server 就使用 :6000#vi /etc/sysconfig/vncservers #VNCSERVERS="2:myusername" //預設值 #VNCSERVERARGS="-geometry 800x600 -nolisten tcp -nohttpd -localhost" VNCSERVERS="100:weithenn" //新增此行 VNCSERVERARGS="-geometry 1024x768" //指定屆時連接到 Xwindows 的解析度步驟2.啟動 VNC Service
再啟動 VNC Service 以前我們先設定屆時連接 VNC Server 的 Password,記得密碼必須超過 6 個字元否則會出現 Password must be at least 6 characters - try again 訊息請您加強密碼強度,當 VNC Password 設定後會自動建立密碼檔我的例子就會建在 /home/user/weithenn/.vnc/passwd。 #vncpasswd Password:                      //輸入 VNC 密碼 Verify:                        //再輸入一次 VNC 密碼以確認
設定完密碼後啟動 VNC Service 吧。 #/etc/rc.d/init.d/vncserver start Starting VNC server: 100:weithenn xauth:creating new authority file /home/user/weithenn/.Xauthority New 'centos-jiakai.weithenn.idv.tw:100 (weithenn)' desktop is centos-jiakai.weithenn.idv.tw:100 Creating default startup script /home/user/weithenn/.vnc/xstartup Starting applications specified in /home/user/weithenn/.vnc/xstartup Log file is /home/user/weithenn/.vnc/centos-jiakai.weithenn.idv.tw:100.log                                                               
Windows 當 VNC Client 的話就下載 吧,安裝完畢後輸入要連接的 VNC Server 及剛才設定的 Port :6000,若正確的話就會跳出密碼認證視窗。
http://lh5.ggpht.com/_GTuTuBNvS8s/SfBi793ZOPI/AAAAAAAAWhk/qhFoV5jothc/s220/vnc1.jpg
但此時應該是看到如下畫面醜醜的畫面 (twm window manager)
http://lh6.ggpht.com/_GTuTuBNvS8s/SfBi8KqtELI/AAAAAAAAWhs/oM2f7iHG9mk/s220/vnc2.jpg
所以我們透過修改 ~/.vnc/xstartup 來讓連接時變成你所安裝的 X-Win (Gnome or KDE) #vi ~/.vnc/xstartup # Uncomment the following two lines for normal desktop: unset SESSION_MANAGER                        //將此行 mark 拿掉 exec /etc/X11/xinit/xinitrc                  //將此行 mark 拿掉
修改後記得重新啟動 VNC Service 才會載入新的設定 #/etc/rc.d/init.d/vncserver restart Shutting down VNC server: 100:weithenn                      Starting VNC server: 100:weithenn New 'centos-jiakai.weithenn.idv.tw:100 (weithenn)' desktop is centos-jiakai.weithenn.idv.tw:100 Starting applications specified in /home/user/weithenn/.vnc/xstartup Log file is /home/user/weithenn/.vnc/centos-jiakai.weithenn.idv.tw:100.log                                                         
檢查相關 Listen Port 是否正確執行 #netstat -tnl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address               Foreign Address             State tcp      0      0 0.0.0.0:6000                0.0.0.0:*                   LISTEN
檢查相關 Process 是否正確執行 #ps ax |grep Xvnc 20116 ?      S      0:00 Xvnc :100 -desktop centos-test.weithenn.idv.tw:100 (weithenn) -httpd /usr/share/vnc/classes -auth /home/user/weithenn/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /home/user/weithenn/.vnc/passwd -rfbport 6000 -pn
此時我們在連到 VNC Server 應該會看到你所安裝的 X-Win {Gnome (左下圖) or KDE (右下圖)}
http://lh3.ggpht.com/_GTuTuBNvS8s/SfBi8V0hviI/AAAAAAAAWh0/9T8VZ-0hrgA/s220/vnc3.jpg http://lh6.ggpht.com/_GTuTuBNvS8s/SfBi8VJ0EsI/AAAAAAAAWh8/HGKZCkleIs4/s220/vnc4.jpg步驟3.設定開機自動啟動 vncserver 服務
使用 chkconfig 指令來查看 vncserver 在各 runlevel 下狀態 #chkconfig --list |grep vncserver vncserver      0:off   1:off   2:off   3:off   4:off   5:off   6:off
設定 lighttpd 在 runlevel 為 2、3、5 時會啟動服務 #chkconfig --levels 235 vncserver on   
檢查剛才的設定是否生效 #chkconfig --list |grep vncserver vncserver      0:off   1:off   2:on    3:on    4:off   5:on    6:off

婧朗蕙 發表於 2013-11-9 01:09:35

暈死也不多加點分

wu06m06 發表於 2013-11-9 01:09:35

初來乍到,請多多關照。。。
頁: [1]
查看完整版本: Linux.CentOS 下VNCServer安裝與設定