确保桌面已安装
yum -y install xorg-x11-app*
yum -y install tigervnc tigervnc-server tigervnc-server-module
cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service
vim /etc/systemd/system/[email protected]:1.service
[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 root -c "/usr/bin/vncserver %i"
# 一般账号
PIDFile=/home/root/.vnc/%H%i.pid
# root账号
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :‘
vncpasswd
systemctl daemon-reload
systemctl start [email protected]:1.service
systemctl enable [email protected]:1.service
vncserver -list
# firewall-cmd --permanent --add-service="vnc-server" --zone="public"
# firewall-cmd --reload
ip:5901(ip:1)