CentOS 5服务器安装VNC时灰屏的解决方法
CentOS 5下安装配置VNC 时灰屏的解决方法
第一个原因 :服务器没有安装gonme kde
yum groupinstall “X Window System” “GNOME Desktop Environment”
1.检查VNC客户端和服务器端是否已安装
执行如下命令:
rpm -q vnc vnc-server
假如返回类似如下信息,
package vnc is not installed
vnc-server-4.0-8.1
则说明系统已默认安装了vnc服务器端(一般来说,系统都默认安装了vnc server)。
2. 将用户名加入到配置文档中
使用如下命令编辑配置文档,添加帐户信息:
vi /etc/sysconfig/vncservers
修改为:
#
# 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”
# VNCSERVERS=”1:gavin 2:john” # use the method for more user
VNCSERVERS=”2:root”
# VNCSERVERARGS[1]=”-geometry 800×600″
VNCSERVERARGS[2]=”-geometry 1024×768″
3.配置 root用户的密码
使用如下命令配置密码:
vncpasswd
当提示Verify时,再次输入密码确认。
4.启动VNC服务
使用如下命令启动VNC SERVER
sbin/service vncserver start
当显示如下信息时,表示启动成功:
Starting VNC server: 2:root [ OK ]
5.修改VNC SERVER的窗口管理器
vnc server默认使用的窗口管理器是twn,这是个很简单的窗口管理器,我们能够改成常用的GNOME或KDE。
先使用如下命令进入用户的home目录:
cd ~/.vnc
编辑启动项:
vi 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” &
gnome-session & #以GNOME作为VNC的窗口管理器
#startkde & #kde desktop
#twm & #注掉系统默认的窗口管理器
第二个原因:
到这里要运行个命令:
chmod u+x /home/user/.vnc/xstartup
否则连远程桌面时会出现灰色屏幕
6.重启VNC SERVER
/sbin/service vncserver restart
当系统提示如下信息时,表示重启成功:
Shutting down VNC server: 2:root [ OK ]
Starting VNC server: 2:root [ OK ]