centos7 vncservice configuration and installation

Posted May 25, 20201 min read

Preliminary preparations:

  • Turn off the firewall, the firewall of centos is firewalld, the command to turn off the firewall
  • systemctl stop firewalld.service

Turn off enforce

  • setenforce 0

centos server version requires GNOME Desktop

  • yum groupinstall "GNOME Desktop"
  1. Install tigervncserver
  • yum install tigervnc-server tigervnc-server-module -y
  1. Copy configuration file
  • cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
  1. Modify the configuration file
  • vim vncserver @:1.service

The content of the configuration file is:

[root @ skong-dzz-20 ~]# cat /lib/systemd/system/vncserver@:1.service

[Unit]
Description = Remote desktop service(VNC)
After = syslog.target network.target
[Service]
Type = forking
ExecStartPre =/bin/sh -c '/usr/bin/vncserver -kill:1>/dev/null 2> & 1 ||:'
ExecStart =/sbin/runuser -l root -c "/usr/bin/vncserver:1 -geometry 1024x768 -depth 24"
PIDFile =/root/.vnc /%H%i.pid
ExecStop =/bin/sh -c '/usr/bin/vncserver -kill:1>/dev/null 2> & 1 ||:'
[Install]
WantedBy = multi-user.target
  1. Enable profile
  • systemctl enable vncserver @:1.service
  1. Set login password
  • vncpasswd
  1. Start vncserver
  • systemctl start vncserver @:1.service
  1. Start status view
  • systemctl status vncserver @:1.service
  1. View port status

netstat -lnt | grep 590 \ *

  1. View error information
  • grep vnc/var/log/messages

image.png

Related Posts