1.安装Gnome桌面
yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y
yum groupinstall "X Window System" "Desktop" -y
2.安装VNC Server
yum install tigervnc tigervnc-server -y
3.配置VNC
a.将/lib/systemd/system/[email protected]文件复制一份
cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service
b.将[email protected]:1.service文件中得<USER>修改为VNC Client连接的账号,这里修改为root了,PIDFile也需要修改下,文件内容如下:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=root
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/usr/bin/vncserver %i
PIDFile=/root/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
c.设置VNCServer密码 vncpasswd
d.启动并设置VNCServer为开机自启动
systemctl start [email protected]:1.service
systemctl enable [email protected]:1.service
如果启动报错:
Job for [email protected]:1.service failed because a configured resource limit was exceeded. See "systemctl status [email protected]:1.service" and "journalctl -xe" for details.
把/root/.vnc/xstartup里的vncserver -kill $DISPLAY注释掉
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
#vncserver -kill $DISPLAY
或者systemctl daemon-reload
或者直接删除/tmp/.X11-unix/目录 rm /tmp/.X11-unix/ -rf
重启服务
vncserver -kill :1
vncserver :1
如果防火墙是enable的,必须保证如下规则
firewall-cmd --permanent --add-service="vnc-server" --zone="public"
firewall-cmd --reload
原文地址:https://www.cnblogs.com/ningcoding-life/p/10943417.html
时间: 2024-10-10 23:50:47