[Environment configuration] centos7 installation vncserver

1. First, you need to install X Window System and GNOME desktop environment. It can be installed with the following command:

```

yum groupinstall "X Window System"

yum groupinstall "GNOME Desktop"

2. Install the VNC server. It can be installed with the following command:

yum install tigervnc-server

3. Configure the VNC server. It can be configured with the following command:

vncserver :1

4. Set the VNC password. It can be set by the following command:

vncpasswd

This setting password is very strict and must be 8 characters, such as Hao1314. This requires upper and lower case characters and cannot be repeated continuously

5. Modify the VNC configuration file. It can be modified by the following command:

vi ~/.vnc/xstartup

Add the following to the file:

#!/bin/sh

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

vncconfig -iconic &

gnome-session &

6. Start the VNC server. It can be started with the following command:

vncserver :1 -geometry 1280x800 -depth 16

7. Install a VNC client, such as RealVNC or UltraVNC, on the Windows system.

8. Connect to the VNC server through the VNC client. Enter the server IP address and port number in the VNC client, such as 192.168.1.100:5901, and then enter the set VNC password to connect to the server.

If you use vnc viewer and forget the password or enter it multiple times, it will cause an error "too many security failures" when connecting. Error, you need to restart the vncserver service at this time

sudo vncserver -kill :1
sudo vncserver :1

vnc common commands:

systemctl daemon-reload # reload
systemctl start vncserver@:1.service # open vnc service

systemctl restart vncserver@:1.service # Turn on the vnc service
systemctl status vncserver@:1.service # Check the status of the vnc service to prevent errors
systemctl enable vncserver@:1.service # Set the vnc service to start every boot

Set up a firewall: because the 590+ port required by vnc may be blocked by the firewall. So open this port:

firewall-cmd --add-port=5901/tcp #Open port 5901
firewall-cmd --add-port=5901/tcp --permanent #Permanently open
firewall-cmd --reload #Reload to make it take effect

references:

1、https://blog.csdn.net/qq_45684208/article/details/122006067

2、http://linux.xiaosiseo.com/post/5643.html

3、https://blog.csdn.net/adminkeys/article/details/124338059

Guess you like

Origin blog.csdn.net/FL1623863129/article/details/132111994