Centos 7 VNC 設定
markdown
安裝VNC Server
```
yum install tigervnc-server
```
複製設定檔
```
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
```
修改 VNC Client 連結的帳號
```
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l USER -c "/usr/bin/vncserver %i"
PIDFile=/home/USER/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
```
建立 VNC Server 密碼
```
su user
vncpasswd
```
設定開機自動啟用
```
systemctl start vncserver@:1.service
systemctl enable vncserver@:1.service
```
確認是否啟用VNC Server虛擬桌面
```
vncserver -list
```
啟用 VNC Server 錯誤
```
systemctl start vncserver@:1.service
Job for vncserver@:1.service failed because the control process exited with error code. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
```
刪除 /tmp/.X11-unix/ 目錄
```
\rm -R /tmp/.X11-unix/
```
設定防火牆允許VNC Server服務
```
firewall-cmd --permanent --add-service="vnc-server" --zone="public"
firewall-cmd --reload
```
查看防火牆zone所開的服務
```
firewall-cmd --zone=public --list-all
```
參考
留言
張貼留言