本文共 4757 字,大约阅读时间需要 15 分钟。
[root@localhost software]# yum install vnc
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnc.x86_64 0:1.0.90-0.17.20110314svn4359.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
tigervnc x86_64 1.0.90-0.17.20110314svn4359.el6 dvd 260 k
Transaction Summary
====================================================================================================================================
Install 1 Package(s)
Total size: 260 k
Installed size: 651 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : tigervnc-1.0.90-0.17.20110314svn4359.el6.x86_64 1/1
Installed products updated.
Verifying : tigervnc-1.0.90-0.17.20110314svn4359.el6.x86_64 1/1
Installed:
tigervnc.x86_64 0:1.0.90-0.17.20110314svn4359.el6
Complete!
执行:
[root@localhost bin]# ls -l vn*
-rwxr-xr-x. 1 root root 594840 Nov 10 2011 vncviewer
查看到已经安装的是vncviewer,相当于客户端。
还需要安装server端:
[root@localhost bin]# yum install tigervnc-server
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.0.90-0.17.20110314svn4359.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
tigervnc-server x86_64 1.0.90-0.17.20110314svn4359.el6 dvd 1.1 M
Transaction Summary
====================================================================================================================================
Install 1 Package(s)
Total download size: 1.1 M
Installed size: 2.8 M
Is this ok [y/N]: y
Downloading Packages:
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64.rpm | 1.1 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64 1/1
Installed products updated.
Verifying : tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64 1/1
Installed:
tigervnc-server.x86_64 0:1.0.90-0.17.20110314svn4359.el6
Complete!
再执行[root@localhost bin]# ls -l vn*
-rwxr-xr-x. 1 root root 86472 Nov 10 2011 vncconfig
-rwxr-xr-x. 1 root root 19912 Nov 10 2011 vncpasswd
-rwxr-xr-x. 1 root root 20085 Nov 10 2011 vncserver
-rwxr-xr-x. 1 root root 594840 Nov 10 2011 vncviewer
可以看到服务端需要的可执行文件都已经安装了,其中vncconfig是用于配置,vncpasswd是用于密码管理。
设置好VNC的密码之后,就可以启动VNC Server了。
[root@localhost ~]# vncserver
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
但此时如果想登录到界面,还需要配置:
1. 防火墙,上面显示的是:1,就需要配置5901端口:
[root@localhost ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
2. 执行xhost +和配置DISPLAY,指示控制台可以显示到哪里,
[root@localhost ~]# xhost +
xhost: unable to open display ""
直接执行xhost +会提示错误,此时应先配置DISPLAY变量:
[root@localhost ~]# export DISPLAY=:0.0
再次执行:
[root@localhost ~]# xhost +
access control disabled, clients can connect from any host
客户端可以从任意host连接。
现在从本机使用vncviewer打开IP,可以显示一个图形界面,但奇怪的是只能看到一些选项,不能登录到界面:
如果配置VNC图形桌面环境为KDE或GNOME桌面环境,还需要配置一个xstartup文件,
[root@testdb ~]# vi /root/.vnc/xstartup
修改文件:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
保存之后重启一下VNCserver服务,方法:
[root@localhost .vnc]# vncserver -kill :1
Killing Xvnc process ID 1527
[root@localhost .vnc]# vncserver
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
转载地址:http://ehltx.baihongyu.com/