步骤如下:

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 ,作者写得很好,如有不明,建议前往围观。

在centOS上安装VNC的更多相关文章

  1. NoSql1 在Linux(CentOS)上安装memcached及使用

    前言:       今天是初五,生活基本要从过年的节奏中回归到正常的生活了,所以想想也该想想与工作有关的事情了.我之前在工作中会经常使用memcached和redis,但是自己一直没有时间系统的好好看 ...

  2. 在Ubuntu|CentOS上安装Shutter截图工具及快捷键设置

    简介 Shutter前身叫GScrot,它是一款相当棒的截图软件. 通过Shutter,你可以截取包括选定区域.全屏幕.窗口.窗口内的控件甚至网页的图像.通过内置的强大插件机制,你可以在截图后,对图像 ...

  3. 在CentOS上安装rabbitmq-server

    ***在 CentOS 6.4上安装python*** 注意啊,自己手动安装python2.7.5,不要动系统上面其他的版本 1,先安装GCC,用如下命令yum install gcc gcc-c++ ...

  4. CentOS上安装软件错误提示:configure: error: no acceptable C compiler found in $PATH

    CentOS上安装软件错误提示:configure: error: no acceptable C compiler found in $PATH 因为是centos linux,默认可以采用yum方 ...

  5. 如何在centos上安装epel源

    一.EPEL是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/Cent ...

  6. 在Centos上安装RabbitMQ流程(转)

    在Centos上安装RabbitMQ流程------------------------ 1. 需求 由于项目中要用到消息队列,经过ActiveMQ与RabbitMQ的比较,最终选择了RabbbitM ...

  7. 在CentOS上安装ZooKeeper集群

    一共准备3个CentOS虚拟机 172.16.9.194 172.16.9.195 172.16.9.196 上传zookeeper-3.3.6.tar.gz到服务器并解压,3台服务器的目录结构如下 ...

  8. CentOS上安装Node.js

    CentOS上安装Node.js [日期:2014-07-21] 来源:Linux社区  作者:maskdfe [字体:大 中 小]     CentOS上安装Node.js(想在Linux上学习No ...

  9. Linux系统入门学习:在CentOS上安装phpMyAdmin

    问题:我正在CentOS上运行一个MySQL/MariaDB服务,并且我想要通过网络接口来用phpMyAdmin来管理数据库.在CentOS上安装phpMyAdmin的最佳方法是什么? phpMyAd ...

随机推荐

  1. jni java C/C++ 相互调用

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha java 中  声明 一个 native 方法 用javah命令 生成 包含 nativ ...

  2. [BZOJ2431][HAOI2009]逆序对数列(DP)

    从小到大加数,根据加入的位置转移,裸的背包DP. #include<cstdio> #include<cstring> #include<algorithm> #d ...

  3. Android 杀掉当前程序的进程

    在销毁所有活动的代码后面再加上杀掉当前进程的代码,以保证程序完全退出,杀掉进程的代码如下所示: android.os.Process.killProcess(android.os.Process.my ...

  4. BZOJ 2818: Gcd 筛法

    2818: Gcd 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=2818 Description 给定整数N,求1<=x,y< ...

  5. leetcode47. Permutations II

    leetcode47. Permutations II 题意: 给定可能包含重复的数字的集合,返回所有可能的唯一排列. 思路: 这题全排列两种写法. 用hash表记录已经visit的数字,虽然看起来很 ...

  6. YII 关联查询

    通过外键自己关联自己

  7. SQl CASE 语句的嵌套使用方式

    case具有两种格式.简单case函数和case搜索函数.  1.简单case函数 case sex when ’1’ then ’男’ when ’2’ then ’女’else ’其他’ end ...

  8. IDA 中文字符串

    http://www.pediy.com/kssd/pediy05/pediy50528.htm Ida Pro 的默认设置里对中文字串的支持比较差,对于首字节大于'E0'的都显示成?了.其实...  ...

  9. 【转】2012年6月26 – 盛大PHP工程师最新面试题

    无笔试. 口试:(前半部分平淡无奇,没什么太难的问题,都是求职岗位基本要会的东西,局限于php.下面是真正进入状态的题.) 谈谈观察者模式是什么?主要应用. 答:类似会有一些server对象时刻侦听某 ...

  10. OOW 2015 MYSQL

    https://events.rainfocus.com/oow15/catalog/oracle.jsp?search.event=openworldEvent&search.mysql=d ...