本文详解在CentOS下安装并配置VNC Server图形化程序
一、VNC Server下载
VNC Server图形化程序下载可在VNC进行下载。
官网下载地址为: https://www.realvnc.com/en/connect/download/vnc/linux/
选择“Linux”->“RPM X64”进行下载。
二、VNC Server安装
1、用管理员身份运行以下命令:
[root@localhost user]# yum install xterm
输出:
已加载插件:fastestmirror, langpacks00000000000000000000000000000
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00
(2/4): extras/7/x86_64/primary_db | 247 kB 00:00
(3/4): updates/7/x86_64/primary_db | 16 MB 00:00
(4/4): base/7/x86_64/primary_db | 6.1 MB 00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 xterm.x86_64.0.295-3.el7_9.1 将被 安装
--> 正在处理依赖关系 libXaw.so.7()(64bit),它被软件包 xterm-295-3.el7_9.1.x86_64 需要
--> 正在检查事务
---> 软件包 libXaw.x86_64.0.1.0.13-4.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
xterm x86_64 295-3.el7_9.1 updates 456 k
为依赖而安装:
libXaw x86_64 1.0.13-4.el7 base 192 k
事务概要
================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:647 k
安装大小:1.7 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/libXaw-1.0.13-4.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
libXaw-1.0.13-4.el7.x86_64.rpm 的公钥尚未安装
(1/2): libXaw-1.0.13-4.el7.x86_64.rpm | 192 kB 00:00
xterm-295-3.el7_9.1.x86_64.rpm 的公钥尚未安装
(2/2): xterm-295-3.el7_9.1.x86_64.rpm | 456 kB 00:00
--------------------------------------------------------------------------------
总计 3.9 MB/s | 647 kB 00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-9.2009.0.el7.centos.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libXaw-1.0.13-4.el7.x86_64 1/2
正在安装 : xterm-295-3.el7_9.1.x86_64 2/2
验证中 : libXaw-1.0.13-4.el7.x86_64 1/2
验证中 : xterm-295-3.el7_9.1.x86_64 2/2
已安装:
xterm.x86_64 0:295-3.el7_9.1
作为依赖被安装:
libXaw.x86_64 0:1.0.13-4.el7
完毕!
切换到.rpm文件所在的文件夹,执行命令:
[root@localhost 下载]# rpm -i VNC-Server-6.9.1-Linux-x64.rpm
输出:
** Moving /usr/bin/Xvnc to /usr/bin/Xvnc.conflict
** Moving /usr/share/man/man1/Xvnc.1.gz to /usr/share/man/man1/Xvnc.1.gz.conflict
** Moving /usr/bin/vncpasswd to /usr/bin/vncpasswd.conflict
** Moving /usr/share/man/man1/vncpasswd.1.gz to /usr/share/man/man1/vncpasswd.1.gz.conflict
Testing if SELinux enabled... [Enabled]
Installing SELinux policy module realvnc-server for SELinux version 17 - this may take a while... [OK]
Installing SELinux policy module realvnc-server-cups for SELinux version 17 - this may take a while... [OK]
Updating /etc/pam.d/vncserver
NOTICE: common configuration in /etc/pam.d contains the following modules:
pam_faildelay.so
pam_fprintd.so
The default vncserver PAM configuration only enables pam_unix. See
`man vncinitconfig' for details on any manual configuration required.
Looking for font path... catalogue:/etc/X11/fontpath.d,built-ins (from xset).
Generating private key... done
Installed systemd unit for VNC Server in Service Mode daemon
Start or stop the service with:
systemctl (start|stop) vncserver-x11-serviced.service
Mark or unmark the service to be started at boot time with:
systemctl (enable|disable) vncserver-x11-serviced.service
Installed systemd unit for VNC Server in Virtual Mode daemon
Start or stop the service with:
systemctl (start|stop) vncserver-virtuald.service
Mark or unmark the service to be started at boot time with:
systemctl (enable|disable) vncserver-virtuald.service
Installed firewalld service configuration. To enable access to VNC services from the public zone, use the following commands:
For VNC Server in Service Mode:
firewall-cmd --zone=public --permanent --add-service=vncserver-x11-serviced
For VNC Server in Virtual Mode daemon:
firewall-cmd --zone=public --permanent --add-service=vncserver-virtuald
三、VNC Server配置
1、 打开安装好的软件,可以按照下图进行操作。
2、登陆账户,或者输入激活码,激活软件。
3、配置密码和加密方式。
4、设置可远程控制的Linux用户。
5、查看配置并确认配置,其中“Conputer IP address”为远程连接时的IP。
6、再次确认之后就完成了,打开角的VNC Server软件,可以看到如下界面,表示配置成功,其中红色方框内的IP地址就是远程连接时需要输入的IP。
四、关闭防火墙和开机自启
VNC图形化程序默认开机自启,我们只需要关闭防火墙即可。
1、打开“防火墙”,可以按照下图进行操作。
2、在“配置”处选择“永久”。
3勾选"vnc-server",重启系统。
全部配置步骤已经完成,可以用VNC客户端进行连接了。
五、注意事项
1、主机IP地址可能变化,IP改变后需用新的IP地址进行连接,建议将主机IP设为固定值,方便连接;
2、将网络设置为“自动连接”,主机重启之后也可以直接进行连接;
3、局域网内进行连接时,需将主机端和客户端的IP地址设置到同一网段下,否则会连接失败;
4、若仍连接失败,可以关闭防火墙,然后进行连接,关闭防火墙可参考下面这篇文章:
CentOS 7开启、查看和关闭防火墙: https://blog.csdn.net/weixin_44934909/article/details/125055529