CentOS8安装VNCServer

CentOS8安装VNCServer

          • 系统信息
          • 安装VNCServer
          • 复制配置文件
          • 编辑复制后的配置文件
          • 开启服务
          • 测试是否VNCServer是否开起来
          • 关闭防火墙或开启端口权限
          • 其他

系统信息
[root@centos8 ~]# cat /etc/redhat-release 
CentOS Linux release 8.1.1911 (Core) 
[root@centos8 ~]# 

注意要安装桌面环境,如果没有安装桌面环境,登进去是黑屏。
处理:
1.安装桌面环境(yum install gnome*
2.重启VNCServer(systemctl restart vncserver@:1.service

安装VNCServer
[root@centos8 ~]# yum install tigervnc-server
CentOS-8 - AppStream                                                     5.6 kB/s | 4.3 kB     00:00    
CentOS-8 - Base                                                          4.5 kB/s | 3.9 kB     00:00    
CentOS-8 - Extras                                                        1.8 kB/s | 1.5 kB     00:00    
Dependencies resolved.
=========================================================================================================
 Package                     Architecture       Version                      Repository             Size
=========================================================================================================
Installing:
 tigervnc-server             x86_64             1.9.0-15.el8_1               AppStream             255 k

Transaction Summary
=========================================================================================================
Install  1 Package

Total download size: 255 k
Installed size: 849 k
Is this ok [y/N]: y
Downloading Packages:
tigervnc-server-1.9.0-15.el8_1.x86_64.rpm                                382 kB/s | 255 kB     00:00    
---------------------------------------------------------------------------------------------------------
Total                                                                    119 kB/s | 255 kB     00:02     
warning: /var/cache/dnf/AppStream-a520ed22b0a8a736/packages/tigervnc-server-1.9.0-15.el8_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS-8 - AppStream                                                     949 kB/s | 1.6 kB     00:00    
Importing GPG key 0x8483C65D:
 Userid     : "CentOS (CentOS Official Signing Key) "
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                 1/1 
  Installing       : tigervnc-server-1.9.0-15.el8_1.x86_64                                           1/1 
  Running scriptlet: tigervnc-server-1.9.0-15.el8_1.x86_64                                           1/1 
  Verifying        : tigervnc-server-1.9.0-15.el8_1.x86_64                                           1/1 

Installed:
  tigervnc-server-1.9.0-15.el8_1.x86_64                                                                  

Complete!
[root@centos8 ~]# 
复制配置文件
[root@centos8 ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
[root@centos8 ~]# 
编辑复制后的配置文件
[root@centos8 ~]# vim /etc/systemd/system/vncserver@\:1.service
[root@centos8 ~]# 
#修改前
ExecStart=/usr/bin/vncserver_wrapper <USER> %i

#把改成要登录的用户名(此处为root)

#修改后
ExecStart=/usr/bin/vncserver_wrapper root %i
开启服务
[root@centos8 ~]# systemctl daemon-reload
[root@centos8 ~]# systemctl start vncserver@:1.service
[root@centos8 ~]# vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used

New 'centos8:1 (root)' desktop is centos8:1

Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/centos8:1.log

[root@centos8 ~]#
测试是否VNCServer是否开起来
[root@centos8 ~]# nc -zv localhost 5901
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Connected to ::1:5901.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
[root@centos8 ~]# 
关闭防火墙或开启端口权限

关闭防火墙

[root@centos8 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-06-21 22:40:18 CST; 14min ago
     Docs: man:firewalld(1)
 Main PID: 890 (firewalld)
    Tasks: 2 (limit: 11460)
   Memory: 29.7M
   CGroup: /system.slice/firewalld.service
           └─890 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid

Jun 21 22:40:16 centos8 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 21 22:40:18 centos8 systemd[1]: Started firewalld - dynamic firewall daemon.
[root@centos8 ~]# systemctl stop firewalld
[root@centos8 ~]# 

开启端口权限
–permanent永久生效,没有此参数重启后失效

[root@centos8 ~]# firewall-cmd --zone=public --add-port=5901/tcp --permanent
success
[root@centos8 ~]# firewall-cmd --reload
success
[root@centos8 ~]# 
其他

亲试SELinux不关也不影响使用

你可能感兴趣的:(Linux)