Install VNC-Server on CentOS 7

First, i logged into my server as root, to make things a little easier. I would recommend doing the same thing to help speed up the processes.

After I logged into the system, I installed VNC-server.

 yum install tigervnc-server

Once all the packages were installed, go ahead and run an update.

yum -y update && yum -y upgrade

Once the system has finished updating, go ahead and copy the following file from /lib to /etc. Before centos 7 the configuration files were stored under /etc/systemd/system.

cp/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

Another thing to consider is the “@:1.service”. “1” being the port it will be used. Some people use 3 which translates to port 5903. I use port 1 which means 5901.

Next well need to allow network traffic on port 5901. After you get an output saying “success” go ahead and restart the firewall.

firewall-cmd --permanent --zone=public --add-service vnc-server
firewall-cmd --reload

Next, you will need to edit a configuration file. Go ahead and copy/paste this part of the config file. Done forget the change the user to fit your system.

vi /etc/systemd/system/vncserver@:1.service
[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=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStart=/sbin/runuser -l jbod -c "/usr/bin/vncserver %i"
PIDFile=/home/jbod/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

 


For this part, well need to log in as the user. The user I am working with is jbod, go ahead and switch over to your user.

su - jbod

Run the following command. It will ask you to input a password, which will be used whenever you try to connect to the server. Make sure to remember the password….

vncserver

Once finished, well need to enable the VNC server. Switch back to root and enter the following commands.

su -
systemctl daemon-reload
systemctl enable vncserver@:1.service

Reboot the server and after you log in, run the following command. If everything has been entered correctly vncserver should run smoothly.

systemctl start vncserver@:1.service

Finally, install the GUI.

yum groupinstall "GNOME Desktop"

I would recommend https://www.realvnc.com/en/ on the client. To connect you will need to enter the ipaddress:port (10.0.0.1:5901)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s