This article introduces how to use tigervnc-server and Server with GUI to access the graphical interface of Linux centos7. All operations were completed on Alibaba Cloud ECS with centos7 installed. Follow the steps to add a graphical interface to centos7.
Steps:
- Install Server with GUI
- Install tigervnc-server
- Configure tigervnc-server
- Configure Alibaba Cloud Security Group
- Connect to the VNC graphical server
1. Install Server with GUI
yum update -y
yum groupinstall -y "Server with GUI"
This step takes about 10 minutes. It’s recommended to use a screen session to install in the background.
2. Install tigervnc-server
useradd vncuser
yum install tigervnc-server
3. Configure tigervnc-server
I don’t want to run VNC as root, so I added a vncuser as the VNC user. Switch to that user and set the VNC password (you need to enter it twice).
su - your_user # If you want to configure VNC server to run under this user directly from CLI without switching users from GUI
vncpasswd
Next, rename the default configuration file.
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Edit the config file username:
vi "/etc/systemd/system/vncserver@:1.service"
Change user
to the username you just added.
Here’s my config file:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l vncuser -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/home/vncuser/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
Then start the VNC service:
systemctl daemon-reload
systemctl start vncserver@:1
systemctl status vncserver@:1
systemctl enable vncserver@:1
Check if port 5901 is open via the network; if yes, it’s successful:
netstat -ano | grep "5901"
4. Configure Alibaba Cloud Security Group
Open port 5901 access in Alibaba Cloud console. Set your own IP address here; if you have a dynamic IP, you can add the ISP-assigned subnet via subnet settings.
5. Connect to the VNC graphical server
I use VNC Viewer to connect to the centos7 VNC server just configured, using IP plus port.
Here’s the connected graphical interface:
Summary
This article introduced how to achieve graphical interface access on centos7 using Server with GUI and tigervnc-server. It provides a good visual solution for centos users or Linux beginners who need a GUI. If you have any questions, feel free to contact the blogger by email for answers.