博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS 6.8 安装vnc
阅读量:7010 次
发布时间:2019-06-28

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

hot3.png

过一段时间就要安装,我写这里复制方便些。

1 查询是否安装了vnc

#rpm -qa |grep vnc

 

2 可以在yum 源上查看vnc软件

#yum list |grep vnctigervnc.x86_64                             1.1.0-24.el6                 @os    tigervnc-server.x86_64                      1.1.0-24.el6                 @os

 

3 安装tigervnc软件

#yum install -y tigervnc#yum install -y tigervnc-server

 

4 配置vnc服务器文件

vim /etc/sysconfig/vncservers

在文件后面添加如下内容:

VNCSERVERS="1:root 2:oracle"VNCSERVERARGS[1]="-geometry 1920x1080 -depth 32 -nolisten tcp"VNCSERVERARGS[2]="-geometry 1920x1080 -depth 32 -nolisten tcp"

解释:这里开启了2个vnc桌面,1号为root的,2号为oracle的,在这里配置的都必须是已有的用户.

下面的参数 就是分辨率,颜色深度,绑定ip等。

这里是vncservers文件: #cat /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:# https://access.redhat.com/knowledge/solutions/7027# 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" (最多可以6个用户)# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"VNCSERVERS="1:root 2:oracle"VNCSERVERARGS[1]="-geometry 1920x1080 -depth 32 -nolisten tcp"VNCSERVERARGS[2]="-geometry 1920x1080 -depth 32 -nolisten tcp"

 

5 使用root执行vncserver 会提示先输入密码,这个密码vnc的链接密码

则还会有

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
提示

我们这里还配置了oracle用户的,我们还需要切换到oracle用户,然后执行vncpasswd,为2号vnc的oracle用户生成vnc的链接密码

注:当然root下,也是只执行vncpasswd生成密码的,

然后统一执行service vncserver start。这样都同样会为root,和oracle用户在他们的家目录生成 .vnc/xstartup文件。

 

6 修改 .vnc/xstartup文件(多个用户都需要修改,如果某个用户没有这个文件则是需要在改用户下启动一下vncserver ,或者 vncserver :2, 或者利用 service vncserver start这样都会为用户创建默认的xstartup文件)

如果是gnome桌面,则把twm & 注释掉,添加gnome-session &

如果是KDE桌面,则把twm & 注释掉,添加startkde &

这里是xstartup文件: #cat .vnc/xstartup 

#!/bin/sh[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18nexport LANGexport SYSFONTvncconfig -iconic &unset SESSION_MANAGERunset DBUS_SESSION_BUS_ADDRESSOS=`uname -s`if [ $OS = 'Linux' ]; then  case "$WINDOWMANAGER" in    *gnome*)      if [ -e /etc/SuSE-release ]; then        PATH=$PATH:/opt/gnome/bin        export PATH      fi      ;;  esacfiif [ -x /etc/X11/xinit/xinitrc ]; then  exec /etc/X11/xinit/xinitrcfiif [ -f /etc/X11/xinit/xinitrc ]; then  exec sh /etc/X11/xinit/xinitrcfi[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresourcesxsetroot -solid greyxterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &#twm &gnome-session &

 

7 启动vncserver 

service vncserver startvncserver :1vncserver -kill:1

vncserver -kill :桌面号    #关闭某个桌面号

vncserver :桌面号    #启动某个桌面号

8 添加开机启动和测试

chkconfig vncserver on

chkconfig vncserver --list

防火墙

service iptables status
添加容许通过的规则,或者直接关闭iptables,如果是添加规则别忘了 service iptables save保存下。

在测试有的是输入ip:加5901,5902这个端口,有的则是ip:1,ip:2这个vnc这个序号,也有因为vnc版本问题链接不成功的。

 

转载于:https://my.oschina.net/lenglingx/blog/1557746

你可能感兴趣的文章
《Servlet和JSP学习指南》一2.2 隐藏域
查看>>
[干货]基础机器学习算法
查看>>
12月14日全球域名商解析量22强:爱名网升至十七
查看>>
全球域名商解析新增量20强:中国占据7个席位
查看>>
在python中获取当前位置所在的行号和函数名
查看>>
如何导出PPT内的所有图片做素材(IT实用技巧)
查看>>
定时自动启动任务crontab命令用法
查看>>
Eclipse工具安装
查看>>
低成本和高性能的MySQL云数据库的实现
查看>>
IIS操作注册表
查看>>
htmlunit入门
查看>>
sql--视图
查看>>
聊天室
查看>>
shell备忘录
查看>>
Spring Boot 2.0 整合 Spring Security Oauth2
查看>>
通过 pecl 快速安装 php-memcached 扩展
查看>>
Java Quartz的cron表达式
查看>>
Import Running in STMS
查看>>
Silverlight+WCF 新手实例 象棋 主界面-事件区-返回退出(三十三)
查看>>
git克隆失败
查看>>