在Centos上安装VNC server
Posted ningcoding-life
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Centos上安装VNC server相关的知识,希望对你有一定的参考价值。
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
以上是关于在Centos上安装VNC server的主要内容,如果未能解决你的问题,请参考以下文章