配置VNC 新整理

来源:互联网 发布:数据挖掘 算法和原理 编辑:程序博客网 时间:2024/05/22 20:28

注意要点:1.必须有开启VNC服务的权限用户. 2.熟悉基本的LINUX命令.[呵呵,因为我也是个新手].下面开工.

1.用SSH 登陆需要配置的服务器开启.VNCSERVER 截图如下.

 

光标移动到VNCSERVER 上 空格选中, 然后TAB 选中 确定退出,这样,我们的VNC服务就开启了[可能需要 reboot 一下服务器,不启动也可以的,但我还是重启了下,因为这个是单独的为了测试搭建的一台服务器,上面没有启动什么服务和部署应用,为了能一次就成功我reboot了一下]

再次SSH登陆到我们的服务器上,下面开始配置了,很简单VI两个文件就可以了,[记得自己开始弄的时候折腾了一下午都没有配置好.后来到一客户那边,装一个WLS和一个10G,因为要用到图形化界面,但GOV的机房,进去太烦琐,就决定直接配置一个远程桌面来操作,配置了N次,最终还是没配起来,今天因为需要测试一个东西,就决定再试试怎么搭建VNC远程桌面的,最开始还是遇到了一个同样的问题就是在执行vi /root/.vnc/xstartup编辑命令的时候 出现了下面的错误

".vnc/xstartup"
".vnc/xstartup" E212: Can't open file for writing
Hit ENTER or type command to continue

记得自己半年前在外地和一兄弟折腾过这东西的,N久没玩了就给忘记了:(在此谢谢单身汉的文章提醒了我.

===========================以下是操作的所有命令 注释部分为色文字标注====================

Last login: Sun Dec 7 07:55:03 2008 from 192.168.89.155
[root@web ~]# cd          #cd到根目录下
[root@web ~]# vncserver     这一步很重要,决定整个个VNC是否能配置成功的关键步骤,如果没有执行这一部在下面VI /root/.vnc/xstartup的时候就会报上面的错误。【个人理解为执行这一步是为了创建一个 /root/.vnc/xstartup
文件和一个为 1 的桌面】

You will require a password to access your desktops.

Password:    输入你配置完成后用VNC登陆用的密码 我设置为123456
Verify:    再次输入

提示创建成功

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

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

 

 

[root@web ~]# vi /root/.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" &
gnome-session& or kde&

# 以上信息我们只需要在xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &后加上 这一句 gnome-session& or kde&
~
~
~
~
~
~
~
~
~
~
~
".vnc/xstartup" 12L, 347C written
[root@web ~]# service vncserver restart   #启动VNC服务器
Shutting down VNC server:                                  [ OK ]
Starting VNC server: no displays configured                [ OK ]
[root@web ~]# vncpasswd
Password:                                                 同上密码123456
Verify:
[root@web ~]# vi /etc/sysconfig/vncservers   编辑这个文件
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# 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/archive/vnc/sshvnc.html>.

# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

# Use "-nohttpd" to prevent web-based VNC clients connecting.

# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.

# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

# VNCSERVERS="1:myusername"
VNCSERVERS="1:root"       #定义登陆用户登陆到的界面
# VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared -depth 24" #定义分辨率和像素
"/etc/sysconfig/vncservers" 27L, 999C written   #提示写入文件成功
[root@web ~]# service vncserver stop             #再次停止服务
Shutting down VNC server: 1:root                           [ OK ]
[root@web ~]# service vncserver start       #启动服务
Starting VNC server: 1:root                       #提示成功
New 'web:1 (root)' desktop is web:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/web:1.log

                                                           [ OK ]
[root@web ~]#

===========================结束=======================

下面就可以用VNC客户端登陆了

在AS3上和AS5上配置测试通过,后附有最终成功登陆界面.

 

 

 

 

 

 

 

 

顺便在此谢谢 单身汉 第一步http://blog.chinaunix.net/u/10070/showart_1206048.html

 

AS3 配置成功后登陆界面,第一步

as5   第二个按照上面的配置 中途REBOOT了一下服务器 用了七分钟,所以说十分钟配置自己的VNC是没有问题的.

AM9:42-9:49vnc2.jpg

原创粉丝点击