1,linux下安裝vnc伺服器
yum install vnc-server
[root@localhost ~]# yum install vnc-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.1.0-8.el6_5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================
Package Arch Version Repository Size
Installing:
tigervnc-server x86_64 1.1.0-8.el6_5 updates 1.1 M
Transaction Summary
Install 1 Package(s)
Total download size: 1.1 M
Installed size: 2.9 M
Is this ok [y/N]: y
Downloading Packages:
tigervnc-server-1.1.0-8.el6_5.x86_64.rpm | 1.1 MB 02:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : tigervnc-server-1.1.0-8.el6_5.x86_64 1/1
Verifying : tigervnc-server-1.1.0-8.el6_5.x86_64 1/1
Installed:
tigervnc-server.x86_64 0:1.1.0-8.el6_5
Complete!
2,配置VNC服務參數檔案
vi /etc/sysconfig/vncservers
編輯vncservers檔案追加如下
#vi /etc/sysconfig/vncsevers VNCSERVERS="1:root 2:ivvr 3:abcd " VNCSERVERARGS[1]="-name root -geometry 1280x720" VNCSERVERARGS[2]="-name ivvr -geometry 800x600" VNCSERVERARGS[3]="-name abcd -geometry 1280x720" 為VNC服務配置了3個使用者root、ivvr和abcd,他們使用的端口号分别為5901、5902和5903,分辨率分别為1280x720、800x600和1280x720。
為使用VNC服務的使用者設定密碼
這一步需要切換到各自的賬戶下使用vncpasswd來生成通路VNC服務的密碼 #su – ivvr $vncpasswd Password: Verify: 這樣在各自家目錄下會生成一個.vnc的隐藏目錄,其下面會生成一個名為passwd的存儲使用者密碼的檔案。
啟動VNC服務
#service vncserver start 或者 #/etc/init.d/vncserver start
修改各使用者桌面環境
啟動VNC服務後在相應的使用者的家目錄下就會生成一個隐藏的vnc目錄和下屬xstartup檔案 $vi /home/ivvr/.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 & #twm & 我們通過注釋twm &且添加gnome-session &來使通過vnc-viewer登陸的使用者使用gnome桌面環境。
重新啟動VNC服務
#service vncserver restart
配置防火牆
在防火牆上為VNC server開啟端口,服務的預設端口是TCP 5900,加上/etc/sysconfig/vncservers檔案裡配置的号,結果就是我們需要開啟的端口,本例子為5901、5902和5903.
2.Widows上的配置
從http://www.tightvnc.com/download.html下載下傳TightVNC。打開輸入VNC服務位址和端口即可
備注:
1. [root@localhost ~]# vncserver
You will require a password to access your desktops.
Password:
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
2. 啟動VNC服務。
#vncserver (啟動vnc伺服器)
關閉VNC服務。
#vncserver -kill :1 (關閉VNC伺服器)
注意:kill和:1之間有一個空格。
啟動 停止 重新開機
#service vncserver start/stop/restart
3. 運作vnc viewer,輸入ip+連接配接号
例如:192.168.2.98:1