[root@VM-0-3-centos /]# yum group list
[root@VM-0-3-centos /]# yum groupinstall "Server with GUI"
[root@VM-0-3-centos /]# systemctl set-default graphical
[root@VM-0-3-centos /]# reboot
[root@VM-0-3-centos /]# yum install -y tigervnc-server
[root@VM-0-3-centos /]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
[root@VM-0-3-centos /]# vi /etc/systemd/system/vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=simple# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver_wrapper <USER> %i #将文中的“<USER>”替换为你系统的用户名rootExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target[root@VM-0-3-centos /]# systemctl daemon-reload
[root@VM-0-3-centos /]# vncpasswd root
Password: #新密码:123456
Verify: #再次输入:123456
Would you like to enter a view-only password (y/n)? n
A view-only password is not used[root@VM-0-3-centos /]#systemctl enable vncserver@:1.service
然后开启vnc服务
[root@VM-0-3-centos /]#systemctl start vncserver@:1.service
查看是否启动成功
[root@VM-0-3-centos /]#systemctl status vncserver@:1.service
//临时关闭
[root@VM-0-3-centos /]#systemctl stop firewalld
//禁止开机启动
[root@VM-0-3-centos /]#systemctl disable firewalld
腾讯云CentOS8 搭建图形界面VNC
最新推荐文章于 2025-03-21 14:59:26 发布