久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Linux環境VNC服務如何安裝、配置與使用

140次閱讀
沒有評論

共計 4319 個字符,預計需要花費 11 分鐘才能閱讀完成。

這篇文章給大家分享的是有關 Linux 環境 VNC 服務如何安裝、配置與使用的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。

1. 確認 VNC 是否安裝
默認情況下,Red Hat Enterprise Linux 安裝程序會將 VNC 服務安裝在系統上。
確認是否已經安裝 VNC 服務及查看安裝的 VNC 版本
[root@testdb ~]# rpm -q vnc-server
vnc-server-4.1.2-9.el5
[root@testdb ~]#

若系統沒有安裝, 可以到操作系統安裝盤的 Server 目錄下找到 VNC 服務的 RPM 安裝包 vnc-server-4.1.2-9.el5.x86_64.rpm,安裝命令如下
rpm -ivh /mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm

2. 啟動 VNC 服務
使用 vncserver 命令啟動 VNC 服務,命令格式為“vncserver : 桌面號”,其中“桌面號”用“數字”的方式表示,每個用戶連個需要占用 1 個桌面
啟動編號為 1 的桌面示例如下
[root@testdb ~]# vncserver :1

You will require a password to access your desktops.

Password:
Verify:
xauth:  creating new authority file /root/.Xauthority

New testdb:1 (root) desktop is testdb:1

Creating default startup script. /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

以上命令執行的過程中,因為是第一次執行,需要輸入密碼,這個密碼被加密保存在用戶主目錄下的.vnc 子目錄(/root/.vnc/passwd)中;同時在用戶主目錄下的.vnc 子目錄中為用戶自動建立 xstartup 配置文件(/root/.vnc/xstartup),在每次啟動 VND 服務時,都會讀取該文件中的配置信息。
BTW:/root/.vnc/ 目錄下還有一個“testdb:1.pid”文件,這個文件記錄著啟動 VNC 后對應后天操作系統的進程號,用于停止 VNC 服務時準確定位進程號。

3.VNC 服務使用的端口號與桌面號的關系
VNC 服務使用的端口號與桌面號相關,VNC 使用 TCP 端口從 5900 開始,對應關系如下
桌面號為“1”  —-  端口號為 5901
桌面號為“2”  —-  端口號為 5902
桌面號為“3”  —-  端口號為 5903
……
基于 Java 的 VNC 客戶程序 Web 服務 TCP 端口從 5800 開始,也是與桌面號相關,對應關系如下
桌面號為“1”  —-  端口號為 5801
桌面號為“2”  —-  端口號為 5802
桌面號為“3”  —-  端口號為 5803
……
基于上面的介紹,如果 Linux 開啟了防火墻功能,就需要手工開啟相應的端口,以開啟桌面號為“1”相應的端口為例,命令如下
[root@testdb ~]# iptables -I INPUT -p tcp –dport 5901 -j ACCEPT
[root@testdb ~]# iptables -I INPUT -p tcp –dport 5801 -j ACCEPT

4. 測試 VNC 服務
第一種方法是使用 VNC Viewer 軟件登陸測試,操作流程如下
啟動 VNC Viewer 軟件  — Server 輸入“144.194.192.183:1”—   點擊“OK”— Password 輸入登陸密碼  —   點擊“OK”登陸到 X -Window 圖形桌面環境  —   測試成功
第二種方法是使用 Web 瀏覽器(如 Firefox,IE,Safari)登陸測試,操作流程如下
地址欄輸入 http://144.194.192.183:5801/ —   出現 VNC viewer for Java(此工具是使用 Java 編寫的 VNC 客戶端程序)界面,同時跳出 VNC viewer 對話框,在 Server 處輸入“144.194.192.183:1”點擊“OK”— Password 輸入登陸密碼  —   點擊“OK”登陸到 X -Window 圖形桌面環境  —   測試成功
(注:VNC viewer for Java 需要 JRE 支持,如果頁面無法顯示,表示沒有安裝 JRE,可以到 http://java.sun.com/javase/downloads/index_jdk5.jsp 這里下載最新的 JRE 進行安裝)

5. 配置 VNC 圖形桌面環境為 KDE 或 GNOME 桌面環境
如果您是按照我的上面方法進行的配置的,登陸到桌面后效果是非常簡單的,只有一個 Shell 可供使用,這是為什么呢?怎么才能看到可愛并且美麗的 KDE 或 GNOME 桌面環境呢?回答如下
之所以那么的難看,是因為 VNC 服務默認使用的是 twm 圖形桌面環境的,可以在 VNC 的配置文件 xstartup 中對其進行修改,先看一下這個配置文件
[root@testdb ~]# vi /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 80×24+10+10 -ls -title $VNCDESKTOP Desktop
twm

將這個 xstartup 文件的最后一行修改為“startkde”,再重新啟動 vncserver 服務后就可以登陸到 KDE 桌面環境
將這個 xstartup 文件的最后一行修改為“gnome-session”,再重新啟動 vncserver 服務后就可以登陸到 GNOME 桌面環境

重新啟動 vncserver 服務的方法:
[root@testdb ~]# vncserver -kill :1
[root@testdb ~]# vncserver :1

6. 配置多個桌面
可以使用如下的方法啟動多個桌面的 VNC
vncserver :1
vncserver :2
vncserver :3
……
但是這種手工啟動的方法在服務器重新啟動之后將失效,因此,下面介紹如何讓系統自動管理多個桌面的 VNC,方法是將需要自動管理的信息添加到 /etc/sysconfig/vncservers 配置文件中,先以桌面 1 為 root 用戶桌面 2 為 oracle 用戶為例進行配置如下:
格式為:VNCSERVERS= 桌面號: 使用的用戶名 桌面號: 使用的用戶名
[root@testdb ~]# vi /etc/sysconfig/vncservers
VNCSERVERS= 1:root 2:oracle
VNCSERVERARGS[1]= -geometry 1024×768
VNCSERVERARGS[2]= -geometry 1024×768

7. 修改 VNC 訪問的密碼
使用命令 vncpasswd 對不同用戶的 VNC 的密碼進行修改,一定要注意,如果配置了不同用戶的 VNC 需要分別到各自用戶中進行修改,例如在我的這個實驗中,root 用戶和 oracle 用戶需要分別修改,修改過程如下:
[root@testdb ~]# vncpasswd
Password:
Verify:
[root@testdb ~]#

8. 啟動和停止 VNC 服務
1)啟動 VNC 服務命令
[root@testdb ~]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New testdb:1 (root) desktop is testdb:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

2:oracle
New testdb:2 (oracle) desktop is testdb:2

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log

  [  OK ]
2)停止 VNC 服務命令
[root@testdb ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:oracle  [  OK ]

3)重新啟動 VNC 服務命令
[root@testdb ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:oracle  [  OK ]
Starting VNC server: 1:root
New testdb:1 (root) desktop is testdb:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/testdb:1.log

2:oracle
New testdb:2 (oracle) desktop is testdb:2

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/testdb:2.log

  [  OK ]

4)設置 VNC 服務隨系統啟動自動加載
第一種方法:使用“ntsysv”命令啟動圖形化服務配置程序,在 vncserver 服務前加上星號,點擊確定,配置完成。
第二種方法:使用“chkconfig”在命令行模式下進行操作,命令使用如下(預知 chkconfig 詳細使用方法請自助式 man 一下)
[root@testdb ~]# chkconfig vncserver on
[root@testdb ~]# chkconfig –list vncserver
vncserver  0:off  1:off  2:on  3:on  4:on  5:on  6:off

感謝各位的閱讀!關于“Linux 環境 VNC 服務如何安裝、配置與使用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-24發表,共計4319字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 孝感市| 土默特左旗| 柘城县| 镇巴县| 大理市| 昭通市| 彭水| 铁力市| 抚松县| 区。| 太白县| 茌平县| 科技| 江安县| 乌兰浩特市| 留坝县| 龙岩市| 齐齐哈尔市| 龙陵县| 永登县| 漠河县| 项城市| 屯昌县| 永昌县| 固安县| 聊城市| 灌阳县| 尖扎县| 唐山市| 房产| 洪泽县| 淮南市| 宜春市| 六枝特区| 泸州市| 南丹县| 富阳市| 莫力| 忻城县| 迁西县| 北海市|