Centos7.2 deployment vnc service record

Without going into too much introduction, the following will directly record the operation record of installing and configuring vncserver under the centos7 system

1 ) Turn off the firewall
The centos firewall is firewalld, the command to turn off the firewall
[ root@localhost ~]# systemctl stop firewalld.service #stop firewall
[ root@localhost ~]# systemctl disable firewalld.service #Prohibit firewall from booting up

[ root@localhost ~]# setenforce 0
[ root@localhost ~]# getenforce
[ root@localhost ~]# cat /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted

2 )install software:
[ root@localhost ~]# yum update
[ root@localhost ~]# yum groupinstall "GNOME Desktop" "X Window System" "Desktop"
[ root@localhost ~]# yum install tigervnc-server tigervnc vnc vnc-server

3 ) Configure vnc connection
[ root@localhost ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
Modify /etc/systemd/system/vncserver@:1.service
Find this line
ExecStart=/sbin/runuser -l -c "/usr/bin/vncserver %i"
PIDFile=/home//.vnc/%H%i.pid

Here I log in directly with the root user, so I replaced it with
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

If it is another user, for example, replace john as follows
ExecStart=/sbin/runuser -l john -c "/usr/bin/vncserver %i"
PIDFile=/home/john/.vnc/%H%i.pid

As the root user logs in directly, the configuration is as follows:
[ root@localhost ~]# cat /etc/systemd/system/vncserver@:1.service
.........
[ Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[ Service]
Type=forking

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

Set a password for VNC
[ root@localhost ~]# vncpasswd
123456

[ root@localhost ~]# vim /etc/libvirt/qemu.conf
vnc_password = "123456"
vnc_listen = "0.0.0.0"

Reload systemd
[ root@localhost ~]# systemctl daemon-reload

Start vnc
[ root@localhost ~]# systemctl enable vncserver@:1.service
[ root@localhost ~]# systemctl start vncserver@:1.service

Note that the firewall is turned off here
If the firewall is enabled, you need to enable the following rules:
[ root@localhost ~]# firewall-cmd --permanent --add-service vnc-server
[ root@localhost ~]# systemctl restart firewalld.service
If it is iptable, you need to add in /etc/sysconfig/iptables:

Close vnc connection
[ root@localhost ~]# /usr/bin/vncserver -kill :1

Test vnc connection:
[ root@localhost ~]# novnc_server --vnc 192.168.1.8:5901 --listen 6081
Warning: could not find self.pem
Starting webserver and WebSockets proxy on port 6081
WebSocket server settings:

Navigate to this URL:

http://kvm-server:6081/vnc.html?host=kvm-server&port=6081 #http access method

Press Ctrl-C to exit

Since the host name of kvm-server is 112.112.113.56 for ip, input in the browser:
http://112.112.113.56:6081/vnc.html?host=112.112.113.56&port=6081

Recommended Posts

Centos7.2 deployment vnc service record
Centos6.8 deploy vnc service
CentOS7.6 server deployment VNC
RabbitMQ cluster deployment record under Centos6.9
Elasticsearch cluster deployment record under CentOS7
FFmpeg environment deployment record under centos7
PPTP environment deployment record under Centos
Complete deployment record for LDAP under Centos7.2
CentOS deployment Harbor
CentOS 8 enable NTP service
CentOS 7 install Docker service
CentOS server deployment (YUM)
CentOS 7 deploys RabbitMQ service
CentOS 7 deploy saltstack service
CentOS7 deploys NFS service
Centos7 build DNS service
SFTP dual-machine high availability environment deployment record under Centos
[CentOS environment deployment] Java7/Java8 deployment under CentOS
CentOS7 deploy vsftp (FTP) service
CentOs7.3 build Solr stand-alone service
Centos 7 mini installation process record
CentOs7.3 build RabbitMQ 3.6 stand-alone service
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Deployment of graphite on centos7
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
CentOS 6.x installation mysql5.7 record
centos6.5: gcc upgrade (5.2.0) process record
CentOs7.3 build SolrCloud cluster service
Centos backend system setup record
Ceph rapid deployment (Centos7 + Jewel)
CentOS 7 set up NTP, SSH service
Centos6.5 installation and deployment of KVM
CentOS builds a cloud service platform
CentOS 7 Tomcat service installation and configuration
CentOS deployment method of flask project
CentOs7 installation and deployment Zabbix3.4 original
Erlang 20.2 installation and deployment under CentOS 7
k8s practice (1): Centos 7.6 deployment k8s (v1.14.2) cluster