环境:rhel4.8
图像界面:GNOME
一:安装
1:装载光驱
rhel 4.8光盘放入光驱
#cd /mnt
#mkdir cdrom
#mount /dev/cdrom /mnt/cdrom
2:vncserver安装包
位置在
/mnt/cdrom/RedHat/RPMS/vnc-server-4.0-12.el4_7.1.i386.rpm
3:安装vncserver
rpm –ivh /mnt/cdrom/RedHat/RPMS/vnc-server-4.0-12.el4_7.1.i386.rpm
4:密码设置
输入vncserver 后出现
Password: 输入密码
Verify:再次输入密码
二:配置
1: vi ~/.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 80×24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session & #set starting GNOME desktop
~
———————————————————
2: vi /etc/sysconfig/vncservers 红色部分为增加部分
————————————————————
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# 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
# <URL:http://www.uk.research.att.com/vnc/sshvnc.html>.
# VNCSERVERS="1:myusername"
# VNCSERVERARGS[1]="-geometry 800×600"
VNCSERVERS="2:root"
VNCSERVERARGS[1]="-geometry 800×600"
————————————————————
3:重启vncserver
service vncserver restart
4:可以查看了。
部分命令
控制VNC服务
停止服务
[bootsky@bootsky .vnc]$ vncserver -kill :1
Killing Xvnc process ID 4242
代码 :1表示启动VNC服务时监听的地址.服务器启动不止一个VNC服务.
启动服务
[bootsky@bootsky .vnc]$ vncserver 或者 vncserver :1、2、3……
New ‘bootsky:1 (bootsky)’ desktop is bootsky:1
Starting applications specified in /home/bootsky/.vnc/xstartup
Log file is /home/bootsky/.vnc/bootsky:1.log
检测VNC服
检查进程:使用ps查看VNC服务所启动的进程
[bootsky@bootsky bootsky]$ ps -eaf
也可使用启动脚本/etc/init.d/vncserver来检查VNC服务进程:
[bootsky@bootsky bootsky]$ /etc/init.d/vncserver status
Xvnc (pid 4312) 正在运行…
检测端口:使用netstat查看系统端口的启动状态:
[bootsky@bootsky bootsky]$ netstat -alp | grep Xvnc
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 *:5801 *:* LISTEN 4312/Xvnc
tcp 0 0 *:5901 *:* LISTEN 4312/Xvnc
tcp 0 0 *:6001 *:* LISTEN 4312/Xvnc
unix 2 [ ACC ] STREAM LISTENING 16396 4312/Xvnc /tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 16432 4312/Xvnc /tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 16412 4312/Xvnc /tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 16410 4312/Xvnc /tmp/.X11-unix/X1
上述代码中,服务共启动了端口5801 5809 6001.
使用telnet命令连接端口测试:
[bootsky@bootsky bootsky]$ telnet localhost 5801
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
输入命令exit可以退出连接.
检测日志
当配置VNC服务时,提示日志文件的建立,即Log file is /home/bootsky/.vnc/bootsky:1.log
[bootsky@bootsky .vnc]$ less bootsky:1.log
Xvnc version 4.0b4 – built Sep 19 2003 09:32:30
Underlying X server release 40300000, The XFree86 Project, Inc
Thu Mar 13 17:27:40 2008
vncext: VNC extension running!
vncext: Listening for VNC connections on port 5901
vncext: Listening for HTTP connections on port 5801
vncext: created VNC server for screen 0
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Thu Mar 13 17:41:33 2008
HTTPServer: completed HTTP request
从上面虽然能够启动服务,但是还是出现了点错误,在网上搜索了下:都没给出多少具体的解释(可以试试把不必要的今进程多杀下看看).
更改桌面环境
VNC默认使用GNOME的桌面环境,如希望使用KDE桌面,修改# vim/etc/sysconfig/desktopDESKTOP="GNOME"为"KDE".
配置多个桌面号
可以通过# vncserver :1 或 2 活 3……,但是当重启系统后,这些设置都会失效.所以可以修改配置文件/etc/sysconfig/vncserver
格式是: VNCSERVER="桌面号:使用的用户名"
修改访问口令
# vncpasswd
启动和停止VNC服务
# /etc/init.d/vncserver start 或 stop 或 restart
设置VNC服务的自动启动
执行ntsysv命令(如果出现着不到这个命令,则需要修改路径),在根目录的.bash_profile文件中 PATH=$PATH:$HOME/bin:/sbin:/usr/sbin后面的:/sbin:/usr/sbin是自己添加的内容.为了避免重启是命令生效.可以执行# source .bash_profile,然后就选择需要启动的服务即可,空格键表示选中与取消.