10分鐘配置本身的vnc [linux遠程桌面]

注意要點:1.必須有開啓VNC服務的權限用戶. 2.熟悉基本的LINUX命令.[呵呵,由於我也是個新手].下面開工.html

1.用SSH 登錄須要配置的服務器開啓.VNCSERVER 截圖以下.web

 

光標移動到VNCSERVER 上 空格選中, 而後TAB 選中 肯定退出,這樣,咱們的VNC服務就開啓了[可能須要 reboot 一下服務器,不啓動也能夠的,但我仍是重啓了下,由於這個是單獨的爲了測試搭建的一臺服務器,上面沒有啓動什麼服務和部署應用,爲了能一次就成功我reboot了一下]服務器

再次SSH登錄到咱們的服務器上,下面開始配置了,很簡單VI兩個文件就能夠了,[記得本身開始弄的時候折騰了一下午都沒有配置好.後來到一客戶那邊,裝一個WLS和一個10G,由於要用到圖形化界面,但GOV的機房,進去太煩瑣,就決定直接配置一個遠程桌面來操做,配置了N次,最終仍是沒配起來,今天由於須要測試一個東西,就決定再試試怎麼搭建VNC遠程桌面的,最開始仍是遇到了一個一樣的問題就是在執行vi /root/.vnc/xstartup編輯命令的時候 出現了下面的錯誤session

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

記得本身半年前在外地和一兄弟折騰過這東西的,N久沒玩了就給忘記了:(在此謝謝單身漢的文章提醒了我.ssh

===========================如下是操做的全部命令 註釋部分爲■色文字標註====================tcp

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.ui

Password:    輸入你配置完成後用VNC登錄用的密碼 我設置爲123456
Verify:    再次輸入
this

提示建立成功

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

相關文章
相關標籤/搜索