1.确认环境
cat /etc/redhat-release CentOS release 6.7 (Final)
2.拷贝配置文件到当前目录下
cp /lib/systemd/system/vncserver@.service .
3.编辑配置文件
vi vncserver@.service 修改以下地方中的<USER>,两处修改为当前系统用户名: ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" PIDFile=/home/<USER>/.vnc/%H%i.pid 修改后: ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/root/.vnc/%H%i.pid
4.新建脚本start-vnc.sh
#!/bin/bash systemctl set-default graphical.target systemctl stop firewalld yum update yum groupinstall "GNOME Desktop" "X Window System" "Desktop" yum install tigervnc-server tigervnc vnc vnc-server cp vncserver@.servic /etc/systemd/system/vncserver@:1.service systemctl daemon-reload vncserver -kill :1 vncserver
5.vnc设置密码
vncpasswd
6.VNC Viewer访问
百度网盘:https://pan.baidu.com/s/1zHuTLvinGW66cWFiYp292Q 提取码: a96q