How to install and configure vnc in CentOS

Source: Internet
Author: User
In CentOS, perform VNC configuration, check VNC clients and servers, add user names to configuration files, start VNC services, and modify the Windows controller of VNCSERVER. 1. check whether the VNC client and server have been installed and run the following command: [root @ localhost ~] # Run the rpm-qavncvnc-serverpackagevncisnotinst CentOS command to check the VNC client and server, add the user name to the configuration file, start the VNC service, and modify the window controller of the VNCSERVER.
1. check whether the VNC client and server have been installed
Run the following command:
[Root @ localhost ~] # Rpm-qa vnc-server
Package vnc is not installed
Package vnc-server is not installed
Indicates that the VNC server is not installed in the system. then we will use yum to install the VNC server.
[Root @ localhost ~] # Yum-y install vncvnc-server
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* Base: mirrors.163.com
* Extras: mirrors.163.com
* Updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnc. i686 0. 0.90-0.10.20100115svn3945.el6 setto be updated
---> Package tigervnc-server.i6860: 1.0.90-0.10.20100115svn3945.el6 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
========================================================== ========================================================== ========================================================== ========================================================== ========================
Package Arch Version Repository Size
========================================================== ========================================================== ========================================================== ========================================================== ========================
Installing:
Tigervnc i686 1.0.90-0.10.20100115svn3945.el6 base 252 k
Tigervnc-server i686 1.0.90-0.10.20100115svn3945.el6 base 1.1 M
Transaction Summary
========================================================== ========================================================== ========================================================== ========================================================== ========================
Install 2 Package (s)
Upgrade 0 Package (s)
Total download size: 1.3 M
Installed size: 3.6 M
Downloading Packages:
(1/2): tigervnc-1.0.90-0.10.20100115svn3945.el6.i686.rpm | 252 kB
(2/2): tigervnc-server-1.0.90-0.10.20100115svn3945.el6.i686.rpm | 1.1 MB
Certificate ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 137 kB/s | 1.3 MB
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: tigervnc-1.0.90-0.10.20100115svn3945.el6.i686 1/2
Installing: tigervnc-server-1.0.90-0.10.20100115svn3945.el6.i686 2/2
Installed:
Tigervnc. i6860: 1.0.90-0.10.20100115svn3945.el6 tigervnc-server.i6860: 1.0.90-0.10.20100115svn3945.el6
Complete!
Start the VNC Server service: run the vncserver command to generate a. vnc folder in the current user's home directory)
[Root @ localhost ~] # Vncserver
You will require a password to access your tops.
Password:
Verify:
Xauth: creating new authority file/root/. Xauthority
New 'localhost. localdomain: 1 (root) 'desktop islocalhost. localdomain: 1
Creating default startup script/root/. vnc/xstartup
Starting applications specified in/root/. vnc/xstartup
Log file is/root/. vnc/localhost. localdomain: 1.log
2. add the user name to the configuration file in CentOS
Edit the configuration file of vncservers
[Root @ localhost ~] # Vi/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 willalso
# 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 VNCserver via TCP.
# Use "-localhost" to prevent remote VNC clients connectingt T when
# Doing so through a secure tunnel. See the "-via" option inthe
# 'Man vncviewer 'manual page.
# VNCSERVERS = "2: myusername"
VNCSERVERS = "2: root" # User name root
# VNCSERVERARGS [2] = "-geometry 800x600-nolisten tcp-localhost"
VNCSERVERARGS [2] = "-geometry 1024x768" # Size
3. set the password of the root user
Run the following command to set the password:
[Root @ localhost ~] # Vncpasswd
Password: abc123
Verify: abc123
When Verify is prompted, enter the password again for confirmation.
4. start the VNC service
Run the following command to start the vnc server:
[Root @ localhost ~] #/Sbin/service vncserver start
Starting VNC server: 2: root
New 'localhost. localdomain: 2 (root) 'desktop islocalhost. localdomain: 2
Starting applications specified in/root/. vnc/xstartup
Log file is/root/. vnc/localhost. localdomain: 2.log
[OK]
[Root @ localhost ~] #
If the following information is displayed, the startup is successful.
5. modify the window controller of the VNC SERVER
The default window controller used by the vnc server is twn, which is a very simple window controller. we can change it to common GNOME or KDE.
Run the following command to enter the user's home directory: cd/. vnc
Edit startup item: vi xstartup
Modify the startup item as follows:
[Root @ localhost ~] # Vi/root/. vnc/xstartup
#! /Bin/sh
Vncconfig-iconic &
Unset SESSION_MANAGER
Unset DBUS_SESSION_BUS_ADDRESS
OS = 'uname-s'
If [$ OS = 'Linux ']; then
Case "$ WINDOWMANAGER" in
* Gnome *)
If [-e/etc/SuSE-release]; then
PATH = $ PATH:/opt/gnome/bin
Export PATH
Fi
;;
Esac
Fi
If [-x/etc/X11/xinit/xinitrc]; then
Exec/etc/X11/xinit/xinitrc
Fi
If [-f/etc/X11/xinit/xinitrc]; then
Exec sh/etc/X11/xinit/xinitrc
Fi
[-R $ HOME/. Xresources] & xrdb $ HOME/. Xresources
Xsetroot-solid gray
Xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop "&
Gnome-session & # use GNOME as the Windows controller of VNC
# Startkde # kde desktop
# Twm &
# Twm # remove the default window controller of CentOS
6. restart the vnc server.
When the CentOS system prompts the following information, the restart is successful.
[Root @ localhost ~] #/Sbin/service vncserver restart
Disable VNC server: 2: root [OK]
Starting VNC server: 2: root
New 'localhost. localdomain: 2 (root) 'desktop islocalhost. localdomain: 2
Starting applications specified in/root/. vnc/xstartup
Log file is/root/. vnc/localhost. localdomain: 2.log
[OK]
View the port listened by the vnc server:
[Root @ localhost ~] # Netstat-antulp | grep 59
Tcp 0 00.0.0.0: 5901 0.0.0.0: * LISTEN 3162/Xvnc
Tcp 0 00.0.0.0: 5902 0.0.0.0: * LISTEN 4193/Xvnc
Tcp 0 00.0.0.0: 59473 0.0.0.0: * LISTEN 1153/rpc. statd
Tcp 0 0: 5989: * LISTEN 1501/cimserver
Tcp 0 0: 5900: * LISTEN 3123/vino-server
Tcp 0 0: ffff: 192.168.0.124: 5900: ffff: 192.168.0.145: 3072 ESTABLISHED3123/vino-server
Ports opened by the firewall:
[Root @ localhost ~] #/Sbin/ Iptables-A input-p tcp-mmultiport
Related Article

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.