博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在centOS上安装VNC
阅读量:5966 次
发布时间:2019-06-19

本文共 5555 字,大约阅读时间需要 18 分钟。

步骤如下:

1.搜寻VNC Server
[root@msg45 wasliberty]# yum search tigervnc-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.advancedhosters.com
 * extras: mirrors.advancedhosters.com
 * updates: mirrors.advancedhosters.com
================================= N/S Matched: tigervnc-server =================================
tigervnc-server.x86_64 : A TigerVNC server
tigervnc-server-applet.noarch : Java TigerVNC viewer applet for TigerVNC server
tigervnc-server-module.x86_64 : TigerVNC module to Xorg
  Name and summary matches only, use "search all" for everything.
2.安装VNC Server
[root@msg45 wasliberty]# yum install tigervnc-server.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.advancedhosters.com
 * extras: mirrors.advancedhosters.com
 * updates: mirrors.advancedhosters.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.1.0-5.el6_4.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================
 Package                    Arch              Version                     Repository       Size
================================================================================================
Installing:
 tigervnc-server            x86_64            1.1.0-5.el6_4.1             base            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-5.el6_4.1.x86_64.rpm                               | 1.1 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : tigervnc-server-1.1.0-5.el6_4.1.x86_64                                       1/1
  Verifying  : tigervnc-server-1.1.0-5.el6_4.1.x86_64                                       1/1
Installed:
  tigervnc-server.x86_64 0:1.1.0-5.el6_4.1                                                      
Complete!
[root@msg45 wasliberty]#
3.设置VNC Server密码

注:用#service vncserver start/restart后提示root密码没设时用此命令重设密码。2014年10月16日

[root@msg45 wasliberty]# vncserver

You will require a password to access your desktops.
Password:
Verify:
xauth:  creating new authority file /root/.Xauthority
New 'asg45.watson.ibm.com:1 (root)' desktop is asg45.watson.ibm.com:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/asg45.watson.ibm.com:1.log
[root@msg45 wasliberty]#
4.修改文件/root/.vnc/xstartup,增加最后一行,注释掉倒数第二行。
[root@msg45 wasliberty]# 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 &
~
~
5.修改显示设置,增加最后两行。
[root@msg45 wasliberty]# 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"
~
~
~
~
6.修改/etc/sysconfig/iptables,放开5901端口。
[root@msg45 wasliberty]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-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 5901  -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
~
~
"/etc/sysconfig/iptables" 13L, 490C written
7.重启iptables
[root@msg45 wasliberty]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Flushing firewall rules: [  OK  ]
iptables: Unloading modules: [  OK  ]
iptables: Applying firewall rules: [  OK  ]
[root@msg45 wasliberty]#
8.以下就是关闭和打开VNCServer了。
[root@msg45 wasliberty]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root [  OK  ]
[root@msg45 wasliberty]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New 'asg45.watson.ibm.com:1 (root)' desktop is asg45.watson.ibm.com:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/asg45.watson.ibm.com:1.log
[  OK  ]
之后,就能通过RealVNC工具看了。
上文参考了:http://www.blogjava.net/icewee/archive/2013/02/22/395594.html ,作者写得很好,如有不明,建议前往围观。

转载地址:http://gitax.baihongyu.com/

你可能感兴趣的文章
浅析支付系统的整体架构
查看>>
二位数组
查看>>
unix文件权限
查看>>
Python 模拟鼠键
查看>>
2017-2018-2 20155224『网络对抗技术』Exp7:网络欺诈防范
查看>>
tomcat 搭建
查看>>
Source Code Review
查看>>
分享一下我安装启动Jmeter出错时的解决办法
查看>>
java 调用process
查看>>
用a标签实现submit提交按钮的效果
查看>>
第十周
查看>>
毕向东_Java基础视频教程第20天_IO流(1~4)
查看>>
几图理解BeautifulSoup
查看>>
HashMap内部是如何实现的(转)
查看>>
交互设计[3]--点石成金
查看>>
java实现双向循环链表
查看>>
如何使用缓存提高程序性能
查看>>
【trie树】HDU4825 Xor Sum
查看>>
服务器搭建4 安装其它库
查看>>
CAD绘制栏杆5.10
查看>>