天天看点

Centos 5.6_x64 安装VNC

1、检查是否安装VNC

[root@jw-back ~]# rpm -qa |grep vnc

vnc-4.1.2-14.el5_6.6

gtk-vnc-0.3.8-3.el5

gtk-vnc-python-0.3.8-3.el5

vnc-server-4.1.2-14.el5_6.6

2、没有安装继续安装

[root@jw-back ~]# yum -y install vnc* 

3、VNC启动/停止/重启

[root@jw-back ~]# service vncserver start/stop/restart

    关闭具体的vncserver命令:vncserver -kill :1 vncserver -kill :2

4、设置VNC密码

 [root@jw-back ~]# vncserver :1

You will require a password to access your desktops. 

Password:              //设置密码

Verify:                   //确认密码

xauth:  creating new authority file /root/.Xauthority 

New 'testdb:1 (root)' desktop is testdb:1  

Creating default startup script. /root/.vnc/xstartup 

Starting applications specified in /root/.vnc/xstartup 

Log file is /root/.vnc/testdb:1.log 

 5、VNC服务使用的端口号与桌面号的关系

     VNC服务使用的端口号与桌面号相关,VNC使用TCP端口从5900开始,对应着关系如下:

      桌面号为“1” --------------- 端口号为“5901”

      桌面号为“2” --------------- 端口号为“5902”

      ......以此类推

       基于Java的VNC客户程序Web服务TCP端口从5800开始,也是与桌面号相关,对应关系如下

       桌面号为“1” --------------- 端口号为“5801”

       桌面号为“2” --------------- 端口号为“5802”

6、如果linux开启防火墙的功能,需要手工开启想用的端口;

 [root@jw-back ~]#  iptables -I INPUT -p tcp --dport 5901 -j ACCEPT 

 [root@jw-back ~]#  iptables -I INPUT -p tcp --dport 5801 -j ACCEPT

7、用VNC客户端连接

提示输入密码就成功啦!~~

8、报错

假如连接失败,检查一下防火墙是否关闭,或者是端口问题。

本文转自 kuangling 51CTO博客,原文链接:http://blog.51cto.com/kling/1181565