1. 程式人生 > >使用VNC的一點小注意

使用VNC的一點小注意

VNC服務端安裝:

依次yum安裝,重啟

 yum check-update

 yum groupinstall "X Window System"

yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts

### 設定預設啟動圖形介面#

unlink /etc/systemd/system/default.target

ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

yum install tigervnc-server -y

reboot

配置:

 cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service

vi /etc/systemd/system/[email protected]:1.service 

在這兩中把<USER>替換成root

ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"

PIDFile=/home/<USER

>/.vnc/%H%i.pid

重啟 systemd 

systemctl daemon-reload

設定密碼

sudo vncpasswd

********

開啟服務

sudo systemctl enable [email protected]:1.service

在環境變數裡新增DISPLAY引數

vi /etc/profile

export DISPLAY=localhost:1

source /etc/profile

[[email protected] java]# xhost +

access control disabled, clients can connect from any host

客戶端安裝:

windows下搜尋安裝軟體VNC Viewer,開啟後在上方搜尋欄新增server伺服器的IP:PORT

PORT一般為5900或者5901

遇到過的報錯:

PID file /home/root/.vnc/trs1:1.pid not readable (yet?) after start.

Host name conflict, retrying with trs1-21234

解決方法:

systemctl disable [email protected]:1

systemctl stop [email protected]:1

systemctl enable [email protected]:1

systemctl start [email protected]:1

重啟,在客戶端連線時注意加埠號