Install VNC server on Centos 7

Source: Internet
Author: User

Install VNC server on Centos 7

VNC is a good remote tool, whether based on Windows or Linux, Because I recently learned about Centos, therefore, we are going to build a VNC server on Centos 7 so that I can remotely connect to the server from the client through VNC viewer.

If you have not installed the desktop environment (X Windows), you can run the following command to install the packages. It may take several minutes to install the packages.

[root@localhost~] #yumcheck-update [root@localhost~] #yumgroupinstall"XWindowsSystem" [root@localhost~] #yuminstallgnome-classic-sessiongnome-terminalnautilus-open-terminalcontrol-centerliberation-mono-fonts [root@localhost~] #unlink/etc/systemd/system/default.target [root@localhost~] #ln -sf /lib/systemd/system/graphical .target /etc/systemd/system/default .target [root@localhost~] #reboot

After restart, you can enter the Centos 7 desktop environment.

Step 1 enter the following command to install the VNC package

[root@localhost~]#yuminstalltigervnc-server-y

Step 2 create a file vncserver @: 1. service in the/etc/systemd/system/directory, and copy the instance configuration file/lib/systemd/system/vncserver @. service

[root@localhost~]#cp/lib/systemd/system/vncserver@.service/etc/systemd/system/vncserver@:1.service

Step 3 open and edit the/etc/systemd/system/vncserver @: 1. service file and replace the user item with your username.

[Service]Type=forking#Cleananyexistingfilesin/tmp/.X11-unixenvironmentExecStartPre=/bin/sh-c'/usr/bin/vncserver-kill%i>/dev/null2>&1||:'ExecStart=/sbin/runuser-lroot-c"/usr/bin/vncserver%i"PIDFile=/root/.vnc/%H%i.pid

Note that the root account is used for login, so change <user> to root

Step 4 restart systemd

[root@localhostsystem]#systemctldaemon-reload

Step 5 create a VNC password for the user

[root@localhostsystem]#vncpasswd

Here, the password I created is 123456.

Step 6 enable and start the service

[root@localhostsystem]#systemctlenablevncserver@:1.serviceln-s'/etc/systemd/system/vncserver@:1.service''/etc/systemd/system/multi-user.target.wants/vncserver@:1.service'[root@localhostsystem]#systemctlstartvncserver@:1.service

Step 7 allow the VNC service to pass the Firewall

[root@localhost~]#firewall-cmd--permanent--add-servicevnc-server[root@localhost~]#systemctlrestartfirewalld.service

Now I can remotely view the graphical interface of Centos 7 through the VNC viewer client running on Win10.



We can see the desktop environment of Centos 7.

To stop the VNC service, enter the following command.

[root@localhost~]#systemctlstopvncserver@:1.service

Disable the VNC service from the system (permanent)

[root@localhost~]#systemctldisablevncserver@:1.service

Stop the Firewall Service

[root@localhost~]#systemctlstopfirewall.service

Have a nice day!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.