CentOS 8.x 安装vncserver
1 | https://www.ibm.com/support/pages/how-configure-vnc-server-red-hat-enterprise-linux-8 |
1. 更新yun源
1 | yum update -y |
2. 安装 tigervnc-server tigervnc
1 | yum -y install tigervnc-server tigervnc |
3. 安装 GNOME base-x
1 | yum -y group install GNOME base-x |
4. 让系统直接进入 graphical.target
1 2 | systemctl set-default graphical.target systemctl isolate graphical.target |
5. 用root直接做vncserver账号
1 | vncserver |
6. 配置Xvnc,位于: $HOME/.vnc/config
例如:root用户,就在 /root/.vnc/config ,abc用户就在 /home/abc/.vnc/config
1 | echo 'session=gnome' > ~/.vnc/config |
7. 指定用户是谁
1 | echo ':1=vncuser1' >> /etc/tigervnc/vncserver.users |
8. 复制vncserver@:1.service
1 | cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service |
9. 放行端口
1 2 | firewall-cmd --zone=public --permanent --add-port=5901/tcp && firewall-cmd --zone=public --permanent --add-port=5901/udp firewall-cmd --reload |
10. 开启 vncserver@:1.service ,并且开机自启动
1 2 3 4 5 | systemctl status vncserver@:1.service systemctl start vncserver@:1.service systemctl stop vncserver@:1.service systemctl enable vncserver@:1.service systemctl disable vncserver@:1.service |
11. 查看端口运行情况
1 | ss -atp | grep 5901 |
会返回如下信息:
1 2 | LISTEN 0 5 0.0.0.0:5901 0.0.0.0:* users:(("Xvnc",pid=1671,fd=6)) LISTEN 0 5 [::]:5901 [::]:* users:(("Xvnc",pid=1671,fd=7)) |