CentOS7 installation GUI interface and remote connection implementation

CentOS7 installation GUI interface and remote connection implementation

Use the browser (webdriver)-based selenium technology to crawl data, so the program needs to run in a GUI environment. This article briefly introduces the steps of installing the GUI interface and remote connection in three parts.

Installation GUI interface

Most cloud server vendors provide images without a GUI interface, so you need to install a graphical environment first. This article uses the GNOME desktop environment:

yum -y groups install "GNOME Desktop"

This command will install the necessary packages for the GNOME desktop and then configure the X system to use GNOME:

echo "exec gnome-session" >> ~/.xinitrc

The two commands for installing the KDE or MATE desktop environment are slightly different:

# kde
yum -y groups install "KDE Plasma Workspaces"
echo "exec startkde" >> ~/.xinitrc

#mate
yum --enablerepo=epel -y groups install "MATE Desktop"
​echo "exec /usr/bin/mate-session" >> ~/.xinitrc

The above has installed the GUI desktop environment.

There are two ways to start the desktop environment:

  1. One-time: Enter startx in the terminal;
  2. When the system starts, it enters the desktop environment by default: systemctl set-default graphical.target, then restart;

Install vnc-server

With a desktop environment, you can generally access the desktop remotely through the web terminal provided by the cloud server manufacturer. When using the web terminal, you need to open the browser every time, then log in to the cloud management background and connect again, which is quite troublesome. We adopt the method of remote connection directly from the desktop client, eliminating the need to open the browser and log in to the cloud management background.

There are many remote desktop technologies, such as VNC, TeamViewer, RDP, etc. This article uses the free and widely used VNC.

Install the server first on the server (tigervnc is a branch of tightvnc):

yum install -y tigervnc-server

Then copy a copy of the VNC configuration:

cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

Note the “@:1” in the above command parameter. You can數字1換成30000內的任意數字“5900+number” is the display (listening) port of the program. For example, “@:1” means listening on port 5901.

Edit the configuration file and replace <USER> with the login username for remote connection (if it is root, be sure to remove "/home" from the second <USER> line). Example configuration as root:

# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/[email protected]
# 2. Replace <USER> with the actual user name and edit vncserver
# parameters appropriately
# (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
# PIDFile=/home/<USER>/.vnc/%H%i.pid)
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# with the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.


[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

Next, set the vnc connection password:

vncpasswd

Note that the connection password is different from the login password: the connection password is used to display the remote desktop, and the login password is used by users to log in to the system.

After setting up, start the vnc service:

systemctl daemon-reload
systemctl start vncserver@:1
systemctl enable vncserver@:1

If the firewall is enabled, make sure to allow access to the corresponding ports.

Client Connection

After the server is configured, connect with the client.

VNC is a free technology and many clients support the protocol. This article uses the free "Remote Desktop - VNC" software on the App Store for connection. After opening the software interface is as follows:

Fill in the server address in the input box: vnc://ip:port, where ip is the server's IP or domain name, and port is the listening port, such as 5901. After entering, press Enter. A password input box will pop up. Enter the password set by vncpasswd. If the password is correct, you can see the server's graphical desktop, for example:

Press the Enter key to enter the login interface and enter the login username and password to enter the system:

Next you can do various graphics operations.

refer to

How to install a GUI on top of CentOS 7
How to Install and Configure VNC Server in CentOS 7

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed steps to install MYSQL8.0 on CentOS7.6
  • Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)
  • MySQL 8.0.16 installation and configuration tutorial under CentOS7
  • Detailed tutorial on installing mysql 8.0.13 (rpm) on Centos7
  • CentOS7 uses yum to install mysql 8.0.12
  • Detailed steps for installing and configuring MySQL 8.0 on CentOS
  • Tutorial on installing MySql5.7 in CentOS7.2 and enabling remote connection authorization
  • Reasons and solutions for being unable to remotely connect to MySQL database under CentOS7
  • How to install MySql in CentOS 8 and allow remote connections

<<:  Using JS to implement a small game of aircraft war

>>:  Mysql join query principle knowledge points

Recommend

CSS screen size adaptive implementation example

To achieve CSS screen size adaptation, we must fi...

JavaScript form validation example

HTML forms are commonly used to collect user info...

Summary of front-end knowledge in the Gokudō game

background In the early stages of learning Japane...

Analysis of MySQL duplicate index and redundant index examples

This article uses examples to describe MySQL dupl...

Solution to the Docker container being unable to access the host port

I recently encountered a problem at work. The doc...

Using nginx + fastcgi to implement image recognition server

background A specific device is used to perform i...

Vue complete code to implement single sign-on control

Here is a Vue single sign-on demo for your refere...

Defining the minimum height of the inline element span

The span tag is often used when making HTML web p...

Detailed tutorial on installing MySQL database in Linux environment

1. Install the database 1) yum -y install mysql-s...

How to install binary MySQL on Linux and crack MySQL password

1. Make sure the system has the required libaio s...

Some issues we should pay attention to when designing a web page

Web design, according to personal preferences and ...

Detailed explanation of three ways to set borders in HTML

Three ways to set borders in HTML border-width: 1...

Install MySQL 5.7.18 using rpm package under CentOS 7

I have been using MySQL recently. The article mys...

How to set the style of ordered and unordered list items in CSS

In an unordered list ul>li, the symbol of an u...