在centOS上安装VNC

简介:

步骤如下:

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
















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/xiandedanteng/p/3524370.html,如需转载请自行联系原作者



相关文章
|
10天前
|
Linux 网络安全 Python
linux centos上安装python3.11.x详细完整教程
这篇文章提供了在CentOS系统上安装Python 3.11.x版本的详细步骤,包括下载、解压、安装依赖、编译配置、解决常见错误以及版本验证。
80 1
linux centos上安装python3.11.x详细完整教程
|
2月前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
8天前
|
Unix Linux 开发工具
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
本文详细介绍了如何在官网下载CentOS 8以及在VMware Workstation Pro 16虚拟机上安装CentOS 8的步骤,包括可能出现的问题和解决方案,如vcpu-0错误的处理方法。
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
|
9天前
|
消息中间件 Linux
centos7安装rabbitmq
centos7安装rabbitmq
|
8天前
|
Linux 虚拟化 Windows
完美解决:重新安装VMware Tools灰色。以及共享文件夹的创建(centos8)
这篇文章提供了解决VMware Tools无法重新安装(显示为灰色)问题的步骤,并介绍了如何在CentOS 8上创建和配置VMware共享文件夹。
完美解决:重新安装VMware Tools灰色。以及共享文件夹的创建(centos8)
|
9天前
|
Docker 容器
centos7.3之安装docker
centos7.3之安装docker
|
2月前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
158 8
centos7 mysql安装及配置
|
10天前
|
NoSQL Linux Redis
linux之centos安装redis
linux之centos安装redis
|
1月前
|
存储 Linux Docker
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
关于如何在CentOS 7.6上安装Docker、介绍Docker存储引擎以及服务进程关系的实战案例。
93 3
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
|
5天前
|
缓存 Linux 开发工具
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
14 0
下一篇
无影云桌面