RHEL Tigervnc Server配置及开机自启动
1. Install tigervnc-server
[[email protected] ~]#yum install tigervnc-server.x86_64
2. 设置VNC服务开机自启动
[[email protected] ~]# chkconfig vncserver on [[email protected] ~]# chkconfig --list |grep vnc vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off
3. 关闭防火墙或设置iptables允许VNC的端口
[[email protected] ~]# iptable -F [[email protected] ~]# service iptables save [[email protected] ~]# service iptables restart
4. Add vnc user
[[email protected] ~]# useradd cisco [[email protected] ~]# passwd cisco Changing password for user cisco. New password: BAD PASSWORD: it is based on a dictionary word Retype new password: passwd: all authentication tokens updated successfully.
5. Config “/etc/sysconfig/vncservers”
注意:如果你要配置两个用户,”VNCSERVERARGS”一定要设置3,也就是user+1,否则只能启动一个session
[[email protected] ~]# vim /etc/sysconfig/vncservers VNCSERVERS="1:root 2:cisco" VNCSERVERARGS[3]="-geometry 800x600 -depth 24"
6. 设置root的VNC配置文件
必须以root身份启动一次,才能生成配置文件,root的保留”:1″
记住下面两个文件,一个是xstartup配置文件,另一个是log,如有问题可以查看
[[email protected] ~]# vncserver :1 New 'frank.cisco.com:1 (root)' desktop is frank.cisco.com:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/frank.cisco.com:1.log
twm是一个窗口管理器,不像GNOME和KDE那么庞大和完善,他只帮用户完成简单的任务,因为小所有占用资源少,启动快,但对于现在的硬件来说,没有理由不用GNOME,毕竟方便,好管理,所以把最后一行的”twm”删掉,换成”gnome-session”,如下所示:
[[email protected] ~]# cat .vnc/xstartup #!/bin/sh [ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n export LANG export SYSFONT 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 grey xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm & <<<
7. 设置cisco的VNC配置文件
步骤同上,切换到cisco用户环境下,启动vncserver :2,然后对生成的xstartup进行配置
8. 配置完成,重启确认是否工作
本文出自 Frank's Blog