---
# System prepended metadata

title: 架設VNC伺服器(使用xfce)
tags: [教學, VNC]

---

# 架設VNC伺服器(使用xfce)
###### tags: `教學` `VNC` 
:::info
:boy: **作者：** neverleave0916 
:mailbox_closed: **聯絡資訊：<neverleave0916@gmail.com>**
:point_right: **<font color="#B24B42">修改日期：** 2020/5/11 03:52</font>
:::
>- 在Docker中架設VNC伺服器並遠端連線
> - 軟體版本：
> 
|   Software    | Version |
|:--------------|:--------|
|    Ubunut     | 18.04  |
|    Docker     | 19.03.8 |
| Nividia Driver| 440.82 |
|     CUDA      | 10.2   |

## Step:
1. Install VNC Server (遠端桌面環境將採用xfce):
```console=+
sudo apt-get install vnc4server xfce4 xfce4-goodies
```
2. 建立VNC server的配置檔與user密碼:
```console=+
$ vncpasswd
$ vim ~/.vnc/xstartup
```
```=1
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
#exec startxfce4(註解) 
dbus-launch /usr/bin/startxfce4 &
https://github.com/TigerVNC/tigervnc/issues/592
```
```console=+
$ chmod 755 ~/.vnc/xstartup
```
3. 手動啟動VNC Server:
```console=+
vncserver -geometry 1440x900
```
這個時候我們先測試看看VNC Server可不可以正常工作。

## 故障排除
2021新增：
[vncserver: Wrong type or access mode of /root/.vnc.
](https://blog.csdn.net/wojiushiwo945you/article/details/112034239)


[vnc已開啟,為什麼卻連不上 !?](http://phorum.study-area.org/index.php?topic=39470.0)

```console=
vncserver -kill :1
vncserver -kill :2
vncserver -kill :3
vncserver -kill :4
vncserver -kill :5
rm /tmp/.X11-unix/X1
rm /tmp/.X11-unix/X2
rm /tmp/.X11-unix/X3
rm /tmp/.X11-unix/X4
rm /tmp/.X11-unix/X5
rm /tmp/.X1-lock
rm /tmp/.X2-lock
rm /tmp/.X3-lock
rm /tmp/.X4-lock
rm /tmp/.X5-lock
vncserver -geometry 1440x900
```
conda uninstall dbus
conda install -c conda-forge matplotlib


這些做完後
你接下來又會從:1開始



vncserver -geometry 1440x900 -alwaysshared -fg

### 參考資料：
- [在Ubuntu 18.04 架設VNC Server
](https://go-linux.blogspot.com/2019/01/ubuntu-1804-vnc-server.html)