CentOS解壓安裝novnc
使用yum安裝的novnc不是最新版,所以決定解壓安裝
安裝vncserver
1.vncserver的服務上需要安裝xwindow
CentOS-7
yum -y groupinstall 'Server with GUI'
CentOS-6
yum -y groupinstall "Desktop"
yum -y groupinstall "X Window System"
yum -y groupinstall "Chinese Support"
2.安裝tigervnc-server
yum -y install tigervnc-server
3.啓動vnc服務
vncserver :1
如果是第一次啓動,需要設置密碼,筆者設置的密碼是00000000,並且開了vnc端口5901和6901
You will require a password to access your desktops.
Password:
Verify:
New 'hg1:1 (root)' desktop is hg1:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/hg1:1.log
停止vnc-server的命令是
vncserver -kill :1
安裝novnc
1.下載項目並解壓
wget -O noVNC-1.1.0.tar.gz https://codeload.github.com/novnc/noVNC/tar.gz/v1.1.0
tar -zxf noVNC-1.1.0.tar.gz -C /opt/
2.創建安裝連接
VNC的默認會話不是安全的,需要創建一個安全的VNC連接。創建完畢的證書 `self.pem` 需要放置到 `noVNC/utils` 目錄下,當啓動 noVNC 時,websockify將自動裝載證書。
cd /opt/noVNC-1.1.0/utils/
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
一路回車下去
3.運行 noVNC,連接本機是5901的vnc服務
./launch.sh --vnc localhost:5901
啓動過程中會去克隆websockify,過程如下
No installed websockify, attempting to clone websockify...
Initialized empty Git repository in /opt/noVNC-1.1.0/utils/websockify/.git/
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 4019 (delta 0), reused 1 (delta 0), pack-reused 4014
Receiving objects: 100% (4019/4019), 4.52 MiB | 24 KiB/s, done.
Resolving deltas: 100% (2655/2655), done.
Using local websockify at /opt/noVNC-1.0.0/utils/websockify/run
Starting webserver and WebSockets proxy on port 6080
/opt/noVNC-1.0.0/utils/websockify/websockify/websocket.py:30: UserWarning: no 'numpy' module, HyBi protocol will be slower
warnings.warn("no 'numpy' module, HyBi protocol will be slower")
WebSocket server settings:
- Listen on :6080
- Web server. Web root: /opt/noVNC-1.0.0
- SSL/TLS support
- proxying from :6080 to localhost:5901
Navigate to this URL:
http://hg1:6080/vnc.html?host=hg1&port=6080
Press Ctrl-C to exit
4.打開鏈接,輸入密碼連接
http://192.168.1.100:6080/vnc.html
5.設置端口號並且後臺啓動
nohup ./launch.sh --vnc localhost:5901 --listen 6800 --web /opt/noVNC-1.0.0/ &
效果圖