(转)centos6.5安装VNC
在Linux下用VNC远程桌面是个很不错的玩意。但在CentOS中默认没有安装VNC的。可以用下面语句查询,如果出现下面情况说明没有安装vnc
#rpm -q tigervnc tigervnc-server
package tigervnc is not installed
package tigervnc-server is not installed
yum install tigervnc tigervnc-server
然后就等待安装完成。[root@www.linuxidc.com ~]# vncserver
You will require a password to access your desktops.
Password:<输入vnc登录密码>
Verify:<再次输入vnc登录密码>
#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 &
VNCSERVERS="2:root"
VNCSERVERARGS[1]="-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"
chmod 777 /root/.vnc/xstartup
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
/etc/init.d/vncserver start
然后在windows中用vnc客户端登录

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix