首页 > 代码库 > centos7上建立vnc server

centos7上建立vnc server

centos7跟6比设置方法不一样

yum groupinstall "X Window System" -y
yum grouplist
yum groupinstall "GNOME Desktop" -y
yum install tigervnc* -y

cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:3.service
vi /lib/systemd/system/vncserver@:3.service

修改[Service]段内中的<USER>为需要开启的账户名称,如root,保存退出。

 1 [Service]
 2 Type=simple
 3 # Clean any existing files in /tmp/.X11-unix environment
 4 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || :
 5 ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
 6 PIDFile=/root/.vnc/%H%i.pid
 7 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || :
 8 
 9 [Install]
10 WantedBy=multi-user.target

 

保存后设置VNC用户密码

vncpasswd root

root123


systemctl daemon-reload
systemctl enable vncserver@:3.service
systemctl start vncserver@:3.service


如果启动不起来,做如下操作
rm -rf /tmp/.X11-unix/*


[root@localhost ~]# vncserver -list
TigerVNC server sessions:

X DISPLAY # PROCESS ID
:3 11681

vnc-viewer连接服务器IP:3或者服务器IP::5903. 注意写端口的时候是2个冒号

技术分享

 

centos7上建立vnc server