文章目錄
安裝mutter窗口管理器和xterm終端
$ sudo yum install -y mutter
$ sudo yum install -y xterm
$ which mutter xterm
/usr/bin/mutter
/usr/bin/xterm
# 安裝TigerVNC Server
```bash
$ sudo yum install -y tigervnc-server
$ which vncserver
/usr/bin/vncserver
如果啓動mutter命令時彙報如下錯誤
$ mutter
(mutter:439427): GLib-GIO-ERROR **: 11:00:34.258: Settings schema 'org.gnome.settings-daemon.peripherals.touchscreen' is not installed
Trace/breakpoint trap
則需要安裝依賴的包
$ sudo yum install -y gnome-settings-daemon
創建VNC Server密碼
$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
# 配置VNC Server
```bash
# 調整分辨率至 1680x1200
$ cat ~/.vnc/config
## Supported server options to pass to vncserver upon invocation can be listed
## in this file. See the following manpages for more: vncserver(1) Xvnc(1).
## Several common ones are shown below. Uncomment and modify to your liking.
##
# securitytypes=vncauth,tlsvnc
# desktop=sandbox
# geometry=2000x1200
# localhost
# alwaysshared
geometry=1680x1200
# create the .Xclients file
$ cat ~/.Xclients
/usr/bin/xterm &
/usr/bin/mutter
$ chmod a+x ~/.Xclients
$ ls -l .Xclients
-rwxr-xr-x. 1 tony tony 35 Apr 12 00:54 .Xclients
關閉防火牆和iptables服務
# 防止VNC的偵聽端口被阻擋
$ sudo systemctl stop firewalld
$ sudo systemctl disable firewalld
$ sudo systemctl stop iptables
$ sudo systemctl disable iptables
啓動VNC Server
第一次啓動VNC Server時會提示.Xauthority
文件不存在,可以忽略;VNC Server會自動創建一個。
VNC Server會創建一個桌面,編號爲“:1”,實則偵聽端口5901;如果編號爲“:2”,則偵聽5902;以此類推。
$ vncserver
xauth: file /home/tony/.Xauthority does not exist
New 'controller:1 (tony)' desktop is controller:1
Starting applications specified in /home/tony/.vnc/xstartup
Log file is /home/tony/.vnc/controller:1.log
$ ls -la ~/.Xauthority
-rw-------. 1 tony tony 251 Apr 12 01:11 .Xauthority
安裝VNC Viewer
在Windows下,下載VNC Viewer客戶端軟件。
https://www.realvnc.com/download/file/viewer.files/VNC-Viewer-6.20.113-Windows.exe
連接VNC Server
安裝之後,啓動桌面上的VNC Viewer程序。
點擊File菜單,選中New Connection菜單項,彈出連接窗口,
- 輸入VNC Server的IP地址或機器名,後面跟着要連接的窗口編號,:1或:2
注意:
不要缺少了冒號或者使用空格,或者在冒號後如何網絡端口號,VNC View程序會自動的將窗口編號轉換成端口號。 - 給這個連接起一個名字,例如“controller”。
- 輸入連接密碼,即
vncpasswd
命令設置的密碼。
- 連接到VNC Server的窗口如下,可以看到
xterm
終端已經啓動。
注意:
由於這只是一個最簡單的圖形環境,沒有菜單可以啓動新的終端,儘量不要關閉最初的xterm
終端。如果不小心關閉了最後一個終端,需要登錄到命令行窗口,然後執行如下命令,這樣就可以在圖形桌面獲得一個新的終端了。
$ export DISPLAY=localhost:1
$ xterm &
安裝並啓動一個firefox實驗一下。
列出VNC Server啓動的桌面
$ vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:1 104931
停止VNC Server桌面
$ vncserver -kill :1