CentOS6.5_x64安装VNCserver

来源:互联网 发布:淘宝客服怎么登陆千牛 编辑:程序博客网 时间:2024/04/29 08:48

VNCserver rpm包下载地址:http://rpm.pbone.net/index.php3/stat/4/idpl/15981670/dir/scientific_linux_5/com/vnc-server-4.1.2-14.el5_6.6.x86_64.rpm.html

在服务器端安装VNCserver。

rpm -ivh vnc-server-4.1.2-14.el5_6.6.x86_64.rpm

一、添加启动项

[root@xen ~]# chkconfig --add vncserver
[root@xen ~]# chkconfig vncserver on

二、设置 VNC 密码

[root@xen ~]# vncserver
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xen:1.log

会在当前用户主目录下 生成 .vnc  目录和配置文件

[root@xen ~]# vncpasswd
Password:
Verify:

设置的密码保存在  /root/.vnc/passwd

三、VNC 配置

修改 xstartup 文件 把最后的 twm & 删掉 加上 gnome-session &

[root@xen ~]# cd /root/.vnc/
[root@xen .vnc]# tail -n 3 xstartup
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &

如果直接 启动
[root@xen .vnc]# /etc/init.d/vncserver start
正在启动 VNC 服务器:no displays configured                [失败]

所以要修改  /etc/sysconfig/vncservers 文件添加以下内容
VNCSERVERS="2:root"
# 桌面号:用户    监听 590* 端口
VNCSERVERARGS[2]="-geometry 800x600"

这样修改后,就算 /etc/inittab 启动模式为 3  也可以正常进入图形界面

启动 vncserver
[root@xen ~]# /etc/init.d/vncserver start
正在启动 VNC 服务器:2:root xauth: (stdin):1:  bad display name "xen:2" in "add" command

New 'xen:2 (root)' desktop is xen:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xen:2.log

[root@xen ~]# chkconfig --add vncserver

[root@xen ~]# chkconfig vncserver on

二、设置 VNC 密码 

[root@xen ~]# vncserver

Creating default startup script/root/.vnc/xstartup
Starting applications specified in/root/.vnc/xstartup
Log file is /root/.vnc/xen:1.log

会在当前用户主目录下生成 .vnc  目录和配置文件

[root@xen ~]# vncpasswd
 
Password:
Verify:

设置的密码保存在  /root/.vnc/passwd 

三、VNC 配置 

修改 xstartup 文件把最后的 twm &删掉加上 gnome-session & 

[root@xen ~]# cd /root/.vnc/

[root@xen .vnc]# tail -n 3 xstartup 
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title"$VNCDESKTOP Desktop" &
gnome-session &

如果直接启动
[root@xen .vnc]# /etc/init.d/vncserver start

正在启动 VNC 服务器:no displaysconfigured                [失败]

所以要修改  /etc/sysconfig/vncservers文件添加以下内容
VNCSERVERS="2:root"

# 桌面号:用户    监听 590*端口
VNCSERVERARGS[2]="-geometry 800x600"


这样修改后,就算 /etc/inittab 启动模式为 3  也可以正常进入图形界面

启动 vncserver
[root@xen ~]# /etc/init.d/vncserver start

正在启动 VNC 服务器:2:root xauth: (stdin):1:  bad display name "xen:2"in "add" command

New 'xen:2 (root)' desktop is xen:2


Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/xen:2.log

四、修改防火墙设置:

VNC server 监听的端口从 5900 开始,display:1 的监听 5901,display:2 监听5902,以此类推。

上面设置的display为2(VNCSERVERS="2:root"),加入下面红色的那一行。

# Firewallconfiguration written by system-config-firewall

# Manualcustomization of this file is not recommended.

*filter

:INPUT ACCEPT[0:0]

:FORWARDACCEPT [0:0]

:OUTPUT ACCEPT[0:0]

-A INPUT -mstate --state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -picmp -j ACCEPT

-A INPUT -i lo-j ACCEPT

-A INPUT -mstate --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -mstate --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT

-A INPUT -jREJECT --reject-with icmp-host-prohibited

-A FORWARD -jREJECT --reject-with icmp-host-prohibited

COMMIT


0 0
原创粉丝点击