Centos7 安装 VNC

1.安装桌面系统
yum groupinstall -y "GNOME Desktop"
reboot

2.安装VNC Server
yum install -y tigervnc-server
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

3.修改服务文件
vim vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=root

Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

设置密码
vncpasswd
4.加载服务配置
systemctl daemon-reload
5.服务自启动
systemctl enable vncserver@:1.service
6.启动服务
systemctl restart vncserver@:1.service

7.客户端连接
vnc客户端登陆:IP:5901

8.黑屏处理
通常是桌面软件问题(GNOUM、Xwindow)
1)安装 MATE 桌面:

yum groups install "MATE Desktop"

2)修改 xstartup 文件

vim ~/.vnc/xstartup

!/bin/sh

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
mate-session &

3)重启服务
systemctl restart vncserver@:1.service

你可能感兴趣的:(Centos7 安装 VNC)