VNC Server (CentOS 7 GNOME)
1. 安装VNC服务
sudo yum install tigervnc-server -y
2. 启动VNC服务,设置密码,然后停止
vncserver :1
vncserver -kill :1
3. 配置为开机启动
sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/
sudo vim /etc/systemd/system/vncserver@.service
[Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/usr/sbin/runuser -l USERNAME -c "/usr/bin/vncserver %i" PIDFile=/home/USERNAME/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1.service
经过实验,vnc连上后黑屏可以通过修改xstartup文件解决,只保留前面几行:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec /etc/X11/xinit/xinitrc