在Centos上安装vnc
1、关闭防火墙和selinux
systemctl stop firewalld.service
setenforce 0
2、安装图形支持
yum groups install "GNOME Desktop"
或yum groups install "X Window System"
3、安装vncserver
yum -y install tigervnc-server
4、修改配置文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
vim /etc/systemd/system/vncserver@\:1.service
找到这两行
ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid
我以root登陆,所以修改为
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
5、重新加载systemd
systemctl daemon-reload
6、设置vnc登陆密码
vncpasswd
7、启动vncserver
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
8、查看是否正常启动
ps -ef | grep vnc
至此vncserver搭建完毕。