1.安装 VNC
yum install vnc vnc-server
系统会提示你确认一些选项,输入 "Y" 确认。
首次设置VNC密码 XXXXX 重复输入两次即可。
错误解决1
安装过程中课程出现错误:
- [dix] Could not init font path element /usr/share/X11/fonts/misc, removing from list!
- [dix] Could not init font path element /usr/share/X11/fonts/Type1, removing from list!
- [dix] Could not init font path element /usr/share/fonts/default/Type1, removing from list!
- [dix] Could not init font path element built-ins, removing from list! Fatal server error:
-
could not open default font 'fixed'
- yum install libXfont xorg-x11-xinit xorg-x11-fonts-Type1
错误解决2
安装过程中课程出现错误:
-
-bash vncserver: command not found
解决方法:
- yum install tightvnc-server
2.配置桌面
vi ~/.vnc/xstartup
主要修改最后两行。改为:
- # xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
- # twm &
-
gnome-session &
保存该文件即可。
3.配置登录帐号
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:myusername"
- # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
编辑最后两行,将这两行注释去掉,得到:
- VNCSERVERS="1:root"
-
VNCSERVERARGS[1]="-geometry 1024x768"
如果你有多个帐号,则按照下面格式配置。
- VNCSERVERS="1:user1 2:user2 3:user3"
- VNCSERVERARGS[1]="-geometry 1024×768"
- VNCSERVERARGS[2]="-geometry 1024×768"
- VNCSERVERARGS[3]="-geometry 800×600 -depth 24 -nolisten tcp -nohttpd -localhost" #不支持 tcp,不支持 http 连接,只能在本地测试访问。
如果使用user2,需要对user2用户执行如下操作
- [root@<span style="background-color: rgb(240, 240, 240);">localhost </span>~]#su user2
- [test@<span style="background-color: rgb(240, 240, 240);">localhost </span>~]$mkdir .vnc //*创建.vnc目录,用于保存此用户的vnc配置文件*//
- [test@<span style="background-color: rgb(240, 240, 240);">localhost </span>~]$vncpasswd //*设置user2用户的vnc远程连接密码*//
- [test@<span style="background-color: rgb(240, 240, 240);">localhost </span>~]$su root
- [root@<span style="background-color: rgb(240, 240, 240);">localhost </span>~]#service vncserver restart
4.配置防火墙,系统服务
VNC server 监听的端口从 5900 开始,display:1 的监听 5901,display:2 监听 5902,以此类推。CentOS 的防火墙缺省是不允许连接这些端口的,所以需要使用下面的步骤打开防火墙:
vi /etc/sysconfig/iptables
上面我们只添加了一个 root 帐号和桌面 1,所以这里按照上面的规则,添加一个 "5901" 端口号即可。
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
设置 VNC 自动启动
chkconfig -level 345 vncserver on
本文介绍如何在CentOS系统中安装和配置VNC服务,包括解决安装过程中的常见错误、配置桌面环境、设置登录账户及配置防火墙等内容。

1024

被折叠的 条评论
为什么被折叠?



