Install vnc on Centos7
Centos7 differs greatly from Centos6.x.
In order to install remote desktop on a server, many detours were taken. This blog post is purely for record. If you encounter the same problem in the future, you can trace it back.
1. If your system does not have any vnc software installed, first install vnc
Yum-yinstalltigervnc-servertigervnc
2. For systems earlier than centos 7, configuration is usually required if vnc is installed.
[Root @ localhost ~] # Cat/etc/sysconfig/vncservers # THISFILEHASBEENREPLACEDBY/lib/systemd/system/vncserver @. service
However, as described above, the file to be configured for Centos7 is
[Root @ localhost ~] # Ll/lib/systemd/system/vncserver @. service-rw-r --. 1rootroot1744Jun1014: 15/lib/systemd/system/vncserver @. service
3. The following prompt appears in the file:
# QuickHowTo: #1. copythisfileto/etc/systemd/system/vncserver @: <display>. service #2. edit <USER> andvncserverparametersappropriately # ("runuser-l <USER>-c/usr/bin/vncserver % i-arg1-arg2") #3. run 'systemctldaemon-reload' #4. run 'systemctlenablevncserver @: <display>. service
4. copy a file and change it to vncserver @: 1. service.
[Root @ localhost ~] # Cp/lib/systemd/system/vncserver @. service/lib/systemd/system/vncserver @: 1. service
5. Replace <User> with your current User and % I with 1.
Unzip unitshortdescriptionappsremoteshorttopservice(vnc?after=syslog.targetnetwork.tar get [Service] Type = forking # Cleananyexistingfilesin/tmp /. x11-unixenvironmentExecStartPre =/bin/sh-c '/usr/bin/vncserver-kill: 1>/dev/null2> & 1 |: 'execstart =/sbin/runuser-lroot-c "/usr/bin/vncserver: 1-geometry1280x720-depth24" PIDFile =/root /. vnc/% H % I. pidExecStop =/bin/sh-c '/usr/bin/vncserver-kill: 1>/dev/null2> & 1 |: '{install}wantedby}multi user.tar get
6. Update systemctl
Systemctldaemon-reload
7. Set to auto start
Systemctlenablevncserver @: 1. service
8. Start the vnc service.
Systemctlstartvncserver @: 1. service
9. Add the corresponding port 5901 to iptables (Note: if there are other users, add the port. The default vnc port is 5900 + n)
[Root @ localhostsystem] # cat/etc/sysconfig/iptables # sampleconfigurationforiptablesservice # container-config-firewall # container/servicestothisdefaultconfiguration * filter: INPUTACCEPT [0: 0]: FORWARDACCEPT [0: 0]: OUTPUTACCEPT [0: 0]-AINPUT-mstate -- stateRELATED, ESTABLISHED-jACCEPT-AINPUT-picmp-jACCEPT-AINPUT-ilo-jACCEPT-AINPUT-ptcp-mstate -- stateNEW-mtcp -- dport22-jACCEPT-AINPUT-ptcp-mstate -- stateNEW-mtcp -- dport5901-jACCEPT-AINPUT-jREJECT -- reject-withicmp-host- prohibited-AFORWARD-jREJECT -- reject-withicmp-host-prohibitedCOMMIT
Note:
1. If you do not configure or enable the firewall and connect to the server using VNC Viewer, the error "connect: Connection timed out (10060)" will be reported.
2. This document uses the root user as an example. If other users also need to log on, copy the file
Cp/lib/systemd/system/vncserver @. service/lib/systemd/system/vncserver @: 2. service
At the same time, change % I in the file to 2 and create vncpasswd for the corresponding user.
3. You can access it through UltraVNC, TigerVNC, or RealVNC Viewer. I can use these three tools in win7 to connect to them.
This article is from the Chase blog, please be sure to keep this source http://uchase.blog.51cto.com/880483/1545357