技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機(jī)純凈版,64位旗艦版,綠色軟件,免費(fèi)軟件下載基地!

當(dāng)前位置:主頁 > 教程 > 服務(wù)器類 >

linux下安裝VNC

來源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2019-01-12 18:44┆點(diǎn)擊:

  今天裝了下VNC,解決了不少問題,寫個(gè)教學(xué)貼,給新手們看看,如果你們碰到同樣的問題,就可以迅速解決,無需頭疼甚至放棄了。

  系統(tǒng)環(huán)境

  VM+RHEL5.1

  [root@localhost .vnc]# uname -r

  2.6.18-53.el5xen

  本地XP系統(tǒng)安裝VNCVIEW去控制VM中的RHEL5.1

  下面在LINUX上安裝VNCSERVER

  1、去去下載免費(fèi)版for x86 linux

  2、下載是一個(gè)tar.gz文件,解壓后進(jìn)入文件夾,里面有個(gè)README,請(qǐng)注意這塊不要下載RPM包,依賴問題以及包頭的安全簽名會(huì)讓你很郁悶的。

  3、解壓縮,進(jìn)入該文件夾,按照readme 要求執(zhí)行4步

  % ./vncinstall /usr/local/bin

  % ./vncinstall /usr/local/bin /usr/local/man

  % mkdir -p /usr/local/vnc/classes

  % cp java/* /usr/local/vnc/classes

  4、啟動(dòng)VNCSERVER,輸入連接密碼

  5、可能會(huì)提示linux1x: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

  去下載libstdc++-libc6.2-2.so.3,放到/usr/lib里面, (這個(gè)我碰到了,通過下載這個(gè)SO文件解決了)

  下面這個(gè)方法在這個(gè)版本中不可取,我已經(jīng)試過,是無效的

  在我的系統(tǒng)上ls命令的結(jié)果是 libstdc++.so.5.0.7 libstdc++.so.6.0.8

  libstdc++.so.6.0.8就是我們要找的,給它做個(gè)鏈接

  代碼:

  $ sudo ln -s libstdc++.so.6.0.8 libstdc++-libc6.2-2.so.3

  會(huì)出現(xiàn)如下錯(cuò)誤:

  vncpasswd: symbol lookup error:vncpasswd: undefined symbol: __builtin_vec_new

  看到這個(gè)錯(cuò)感覺就是那兩個(gè)庫不一樣造成的字符未定義

  6、繼續(xù)啟動(dòng)vncserver,可能還有錯(cuò)誤,如下

  vncext: VNC extension running!

  vncext: Listening for VNC connections on port 5901

  vncext: Listening for HTTP connections on port 5801

  vncext: created VNC server for screen 0

  error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy

  Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!

  Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!

  Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!

  Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

  Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!

  Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

  Fatal server error:

  could not open default font 'fixed'

  xsetroot: unable to open display 'localhost.localdomain:1'

  vncconfig: unable to open display "localhost.localdomain:1"

  Warning: This program is an suid-root program or is being run by the root user.

  The full text of the error or warning message cannot be safely formatted

  in this environment. You may get a more descriptive message by running the

  program as a non-root user or by removing the suid bit on the executable.

  xterm Xt error: Can't open display: %s

  原因:vncserver默認(rèn)尋找的X系統(tǒng)的字體路徑在/usr/X11R6/lib/X11/fonts/下,但RHEL5卻在/usr /share/X11/fonts/下

  解決:mkdir /usr/X11R6/lib

  cd /usr/X11R6/lib

  ln -s /usr/share/X11 X11

  7、在XP上啟用vncview,注意,這個(gè)里面填寫的IP地址加桌面號(hào),一般是1,但是如果有多人登錄桌面可能就不是1,需要詢問管理員,如下格式:192.168.1.102:1

  [root@localhost ~]# netstat -an |grep 01

  tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN

  tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN

  tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN

  8 、VNC連接成功后,發(fā)現(xiàn)只有TWM界面,不是傳說中的桌面,修改如下

  去掉中以下兩行前面的#號(hào),讓vnc加載默認(rèn)圖形界面程序

  # unset SESSION_MANAGER

  # exec /etc/X11/xinit/xinitrc

  這兩行可能有些文件中沒有,需要手動(dòng)添加,沒有是顯示不了桌面的

  修改下面這個(gè)東西

  把最后一行 twm& 改成------->gonme-session &

  附:我的配置文件

  #!/bin/sh

  [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

  unset SESSION_MANAGER

  exec /etc/X11/xinit/xinitrc

  xsetroot -solid grey

  vncconfig -iconic &

  xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

  gnome-session &

  ~

  9、日志文件中的錯(cuò)誤

  日志文件位置在root主目錄下的隱藏文件 /root/.vnc/localhost.localdomain:1.log 或者是2.log上,這個(gè)1和2的區(qū)別就是桌面號(hào)了,不同的桌面號(hào)對(duì)應(yīng)的不同的LOG文件

  error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy

  Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!

  Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

  這個(gè)幾個(gè)錯(cuò)誤一直存在,但是目前沒有發(fā)現(xiàn)VNC正常運(yùn)行。請(qǐng)大俠們指點(diǎn)指點(diǎn)。

  BTW:一般桌面號(hào)啟動(dòng)都是1,可以通過命令來控制vncserver :10 那這樣桌面號(hào)就變成10,登錄的時(shí)候就是XX.XX.XX.XX:10就OK了

  10、把VNC加入服務(wù),每次啟動(dòng)自動(dòng)開啟

  這個(gè)就不用說了,chkconfig add即可。