1. Use yum install tigervnc-server to install vnc
2. modify the configuration file
[Root @ localhost ~] # Cat/etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display: user pairs.
#
# Uncomment the lines below to start a VNC server on display: 2
# As my 'myusername' (adjust this to your own). You will also
# Need to set a VNC password; run 'man vncpasswd' to see how
# To do that.
#
# Do not run this service if your local area network is
# Untrusted! For a secure way of using VNC, see this URL:
# Http://kbase.redhat.com/faq/docs/DOC-7028
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-localhost" to prevent remote VNC clients connecting tables t when
# Doing so through a secure tunnel. See the "-via" option in
# 'Man vncviewer 'manual page.
# VNCSERVERS = "10: myusername"
# VNCSERVERARGS [1] = "-geometry 800x600-nolisten tcp-localhost"
Remove # VNCSERVERS = "10: myusername"
# VNCSERVERARGS [1] = "-geometry 800x600-nolisten tcp-localhost" the "#" before the two statements (that is, remove the comment)
Change myusername to the user name you log on to. Set the preceding number. vnc is defined by port + desktop number,
The vnc port is 5900. Here, my desktop number is 10. When connecting to the vnc, the port is 5900 + 10, that is, 5910.
"1" in VNCSERVERARGS [1] indicates that I only open services to one user.
3. Set the password
[Root @ localhost ~] # Vncserver
After entering the vncserver, the system prompts you to set the password.
You will require a password to access your tops.
Password:
Verify:
4. Restart the service
[Root @ localhost ~] # Service vncserver restart
If prompted
Starting VNC server: 1: root
WARNING: The first attempt to start Xvnc failed, possibly because the font
Catalog is not properly configured. Attempting to determine an appropriate
Font path for this system and restart Xvnc using that font path...
Cocould not start Xvnc.
/Usr/bin/Xvnc: symbol lookup error:/usr/bin/Xvnc: undefined symbol: pixman_composite_trapezoids
/Usr/bin/Xvnc: symbol lookup error:/usr/bin/Xvnc: undefined symbol: pixman_composite_trapezoids
Install the missing package.
[root@localhost ~]# yuminstallpixmanpixman-devellibXfont
Restart again.
5. We recommend that you add this port to the firewall and set it to a boot entry.
[root@localhost ~]#
iptables-IINPUT-ptcp--dport5901-jACCEPT
[root@localhost ~]#
Chkconfig vncserver on
6. Restart the firewall.
7. Test the connection on the client. The ip address of my server is 192.168.7.198, enter 192.168.7.198: 10 on the client, and the password is the password set in step 3.