CentOS 6.5 安裝VNC linux
在Linux下用VNC遠程桌面是個很不錯的玩意。但在CentOS中默認沒有安裝VNC的。能夠用下面語句查詢,若是出現下面狀況說明沒有安裝vncwindows
1、檢查桌面程序是否已安裝服務器
#rpm -q 「X Window System」 「Desktop」 「Chinese Support」session
#yum groupinstall -y "X Window System" "Desktop" "Chinese Support" tcp
2、檢查vnc相關服務是否安裝ide
#rpm -q tigervnc tigervnc-server vnc vnc-server ui
package tigervnc is not installedthis
package tigervnc-server is not installedspa
一、安裝VNC服務rest
#yum install tigervnc tigervnc-server vnc vnc-server
而後就等待安裝完成。
二、爲vncserver設置周密碼
[root@www.linuxidc.com ~]# vncserver 或者vncpasswd
You will require a password to access your desktops.
Password:<輸入vnc登陸密碼>
Verify:<再次輸入vnc登陸密碼>
啓動服務:#service vncserver restart
注:若是出現FAILED那通常是配置文件寫錯了,若是檢查後問題依舊,而且錯誤提示與下圖相似那麼則是版本緣由。安裝或更新x11.
命令:yum install pixman pixman-devel libXfont -y
請注意libXfont 裏面的X是大寫的哦。
三、 配置VNC
爲了防黑屏,須要修改一下/root/.vnc/xstartup。
註釋下面兩行
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
而後再添加下面一行
gnome-session &
[root@GUOKE ~]# vi /root/.vnc/xstartup
#!/bin/sh
[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
case "$WINDOWMANAGER" in
*gnome*)
if [ -e /etc/SuSE-release ]; then
PATH=$PATH:/opt/gnome/bin
export PATH
fi
;;
esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
修改用戶配置文件:/etc/sysconfig/vncservers
去掉下面這兩行前的「#」,也就是說把這兩行的註釋給去掉。
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 1024x768 -depth 32"
改完後的配置文件以下
[root@GUOKE ~]# 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 this URL:
# http://kbase.redhat.com/faq/docs/DOC-7028
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# 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:root"
VNCSERVERARGS[2]="-geometry 1024x768 -depth 32"
四、改變xstartup的權限
chmod 777 /root/.vnc/xstartup
五、防火牆開端口,netstat -antpl查看能夠發現有三個端口在監聽。
5901 5801 6001
這三個端口:
默認的, vnc 服務監聽3個TCP端口
RFB(Remote FrameBuffer)協議 默認端口 : 5900 顯示器號
HTTP協議默認端口 : 5800 顯示器號
X協議 默認端口 : 6000 顯示器號
vncserver使用的顯示器編號默認從1開始, 依次使用, 也能夠參數指定端口號
咱們只須要RFB協議就行了,因此,咱們在防火牆中加5900到5903這幾個,這樣就能夠開3個了。
vi /etc/sysconfig/iptables 找到下面的語句:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
在這以後填加:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT
重起防火牆
service iptables restart
六、起動vnc服務器
/etc/init.d/vncserver start
而後在windows中用vnc客戶端登陸