How to install VNC server
How to install VNC server
VNC server is used to connect and control desktop environment of the server from remote clients. VNC viewer is used on remote computer to connect the server. In the article we can learn about how to install vnc server on centos 7 . we can use the default packages provided in the centos yum repository.Install vnc server on centos 7
Let’s start. If you don’t have desktop environment ( X windows ), issue the below commands one by one to install. It will take few minutes to install packages.
After reboot, you will get Centos 7 desktop .
[root@krizna ~]# yum check-update
[root@krizna ~]# yum groupinstall "X Window System"
[root@krizna ~]# yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
[root@krizna ~]# unlink /etc/systemd/system/default.target
[root@krizna ~]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
[root@krizna ~]# reboot
After reboot, you will get Centos 7 desktop .
Now start installing VNC packages.
Step 1 » Issue the below command to install VNC package.
Step 2 » Create a file vncserver@:1.service in /etc/systemd/system/ directory by copying example config file /lib/systemd/system/vncserver@.service
Step 3 » Now open /etc/systemd/system/vncserver@:1.service file and replace with your username .
Find these lines ..
Replace ( Considering username as john )
If you are creating for root user .
Step 4 » Reload systemd for changes.
Step 5 » Create VNC password for the user .
Step 6 » Enable and start the service using the below commands.
Enable service at startup ( Permanent ).
Start the service .
Step 7 » Allow VNC service in firewall.
Now you can able to connect VNC server using IP and Port ( Eg : 192.168.1.10:1 )


You can use VNC client like Tightvnc viewer and Realvnc viewer to connect Server.
For additional users create files with different ports ( Refer Step 2 ) vncserver@:2.service by copying example config file and continue the steps 3,4,5 and 6 by replacing service name. Please make sure you logged in as that particular user for creating vnc password ( Step 5 ).
Step 1 » Issue the below command to install VNC package.
[root@krizna ~]# yum install tigervnc-server -y
Step 2 » Create a file vncserver@:1.service in /etc/systemd/system/ directory by copying example config file /lib/systemd/system/vncserver@.service
[root@krizna ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Step 3 » Now open /etc/systemd/system/vncserver@:1.service file and replace with your username .
Find these lines ..
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid
Replace ( Considering username as john )
ExecStart=/sbin/runuser -l john -c "/usr/bin/vncserver %i"
PIDFile=/home/john/.vnc/%H%i.pid
If you are creating for root user .
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
Step 4 » Reload systemd for changes.
[root@krizna ~]# systemctl daemon-reload
Step 5 » Create VNC password for the user .
[root@krizna ~]# vncpasswd
Step 6 » Enable and start the service using the below commands.
Enable service at startup ( Permanent ).
[root@krizna ~]# systemctl enable vncserver@:1.service
Start the service .
[root@krizna ~]# systemctl start vncserver@:1.service
Step 7 » Allow VNC service in firewall.
[root@krizna ~]# firewall-cmd --permanent --add-service vnc-server
[root@krizna ~]# systemctl restart firewalld.service
Now you can able to connect VNC server using IP and Port ( Eg : 192.168.1.10:1 )
You can use VNC client like Tightvnc viewer and Realvnc viewer to connect Server.
For additional users create files with different ports ( Refer Step 2 ) vncserver@:2.service by copying example config file and continue the steps 3,4,5 and 6 by replacing service name. Please make sure you logged in as that particular user for creating vnc password ( Step 5 ).
Additional Commands :
» To stop VNC service .
» To disable VNC service from startup ( permanent ).
» To stop firewall ( For troubleshooting ).
[root@krizna ~]# systemctl stop vncserver@:1.service
» To disable VNC service from startup ( permanent ).
[root@krizna ~]# systemctl disable vncserver@:1.service
» To stop firewall ( For troubleshooting ).
[root@krizna ~]# systemctl stop firewalld.service
Comments
Post a Comment