CentOS 7.x安装配置VNC Server及桌面环境
CentOS 7.4安装配置VNC Server及桌面环境步骤如下:
安装vnc、Gnome桌面
yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y
yum groupinstall "X Window System" "Desktop" -y
yum install tigervnc tigervnc-server -y
配置VNC
将/lib/systemd/system/vncserver@.service文件复制一份
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service
将vncserver@.service文件中得
cat /etc/systemd/system/vncserver@.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=root
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
设置VNCServer密码:
vncpasswd
启动并设置VNCServer为开机自启动 :1 使当参数启动服务器,表示启动第一个界面
systemctl start vncserver@:1
systemctl enable vncserver@:1
如果启动报错:
Job for vncserver@:1.service failed because the control process exited with error code. See
"systemctl status vncserver@:1.service" and "journalctl -xe" for details.
直接删除/tmp/.X11-unix/目录后,重新启动服务即可
rm /tmp/.X11-unix/ -rf
CentOS7防火墙规则:
firewall-cmd --permanent --add-service="vnc-server" --zone="public"
firewall-cmd --reload
CentOS7.x开机自动进入图形化界面:
systemctl set-default graphical.target(图形界面模式)
reboot(重启系统)
如果不设置进入图形界面,VNC连接以后容易卡住·
附:开机启动字符界面模式
systemctl set-default multi-user.target(字符界面模式)
reboot(重启系统)
查看默认模式:
systemctl get-default
Tag标签:「vnc server 桌面」更新时间:「2021-11-03 20:31:43」阅读次数:「798」