Centos5上配置VNC服务

VNC服务器端机器需要完成如下步骤:

1、安装vnc

yum install vnc*

2、设置vnc服务密码

[root@localhost ~]# vncserver 

You will require a password to access your desktops.

Password:
Verify:
xauth:  creating new authority file /root/.Xauthority

New 'localhost.localdomain:1 (root)' desktop is localhost.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
3、生成配置文件之后,要杀死:1进程

[root@localhost ~]# vncserver -kill :1
Killing Xvnc process ID 3774

4、设置远程桌面类型(KDE还是GNOME),Centos的是GNOME

[root@localhost ~]# vim ~/.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 &
            gnome-session &

5、配置VNC

[root@localhost~]#vim /etc/sysconfig/vncservers
 VNCSERVERS="1:root"
 VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost



甚至也可以启动多个VNC服务,例如

VNCSERVERS= “ 1:user1 2:user2 3:user3 “
VNCSERVERARGS [ 1 ] = “ -geometry 1024×768 “
VNCSERVERARGS [ 2 ] = “ -geometry 1024×768 “
VNCSERVERARGS [ 3 ] = “ -geometry 800×600 -depth 24 -nolisten tcp -nohttpd -localhos
VNCSERVERS这一行是配置在系统启动时启动几个VNC server,上面的例子里运行了三个VNC server,其中user1在display :1,user2在display :2,user3在display :3。VNCSERVERARGS这三行,分别为VNC server 1, 2, 3配置启动参数,上面的例子里对user1和user2使用屏幕分辨率1024×768,对user3使用800×600,24色,不支持tcp,不支持http连接,只能在本地测试访问。  
  
6、重新启动vnc服务
[root@localhost~]#/sbin/service vncserver start

启动失败的原因有:
    第一、/etc/sysconfig/vncservers文件参数不对
    第二、没有为vncservers提到的用户生成各自的配置文件
    第三、在生成配置文件后,没有使用命令vncserver -kill :1 将那个进程杀死

7、最后可以开启防火墙的vncserver的端口

VNC server监听的端口从5900开始,display:1的监听5901,display:2监听5902,以此类推。CentOs的防火墙缺省是不允许连接这些端口的,所以需要使用下面的步骤打开防火墙(需要root权限):

vi /etc/sysconfig/iptables 

找到下面的语句:
-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited

在此行之前,加上下面的内容:

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5900:5903 -j ACCEPT

这句话的含义是,允许其它机器访问本机的5900到5903端口,这样,display:1, display:2, display:3的用户就可以连接到本机。

然后使用root身份重新启动防火墙:

[root@localhost~]#/sbin/service iptables restart


现在客户端输入vncviewer即可连接到VNC server上了。大功告成。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值