Dragon

如果需要使用可视化界面的软件或工具,就必须安装GUI

安装GUI后只能通过服务商提供的网页端VNC连接,使用时鼠标有延迟,体验相对来说不是很好,那么此时选择通过软件连接 vnc 就是很好的选择,类似 windows 系统自带的远程桌面连接,大家或许都有体验吧?

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图

本文使用的服务器腾讯云的 CVM(云服务器),镜像: TencentOS Server 2.4 (TK4)

系统内核版本:CentOS Linux release 7.9 (Final)

推荐使用纯净的系统安装,如果服务器内存在数据,请先在服务器控制台侧创建硬盘快照后再进行操作,数据无价!

1.1、升级系统

考虑到兼容性和安全性及性能问题,首先需要更新系统。

执行下方命令后等待即可。

yum update -y

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图1

1.2、安装GUI(图形用户界面)软件包

执行下方命令安装即可,大约需要安装 600-800MB 左右的包和依赖,执行下方命令后输入”y“后等待下载安装即可。

yum groupinstall "GNOME Desktop" "Graphical Administration Tools"

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图2

1.3、将GUI图形界面设置为首选项

systemctl set-default graphical.target

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图3

1.4、重启服务器

安装GUI后需要重启服务器使GUI界面作为第一启动模式生效

reboot 或 shutdown -r now

1.12  Centos8 系列必看

centos8 系列及以上系统请依次执行下方命令

yum groupinstall "Server with GUI" -y #安装GUI软件包 
systemctl set-default graphical #设置图形界面为第一启动模式 
reboot #重启

剩下的步骤请依次按照下方文章内容进行。

1.5、通过云服务商提供的网页端VNC查看GUI界面

重启服务器后可以通过云服务商提供的网页端VNC客户端查看GUI界面
但是 TencentOS Server 系列安装GUI后通过网页端VNC查看黑屏,当然正常的centos7/8 系列系统也可能会遇到该类情况,不过概率很小,无论是否出现以下情况,都可直接跳过,查看 2.0。
不要慌,教程才写到一半,接下来通过安装VNC Server 实现远程连接 Linux 远程桌面
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图4
主要问题是不显示任何内容,并且执行

startx

启动 X Window,提示错误

xauth:  file /root/.serverauth.9573 does not exist
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System:  4.14.105-19-0006 
Current Operating System: Linux VM-16-7-centos 5.4.119-19-0009.3 #1 SMP Wed Apr 20 22:27:43 CST 2022 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.119-19-0009.3 root=UUID=962910d5-ec2c-4f21-b0e9-eb2307916c9e ro quiet elevator=noop console=ttyS0,115200 console=tty0 vconsole.keymap=us crashkernel=1800M-64G:256M,64G-128G:512M,128G-:768M vconsole.font=latarcyrheb-sun16 net.ifnames=0 biosdevname=0 intel_idle.max_cstate=1 intel_pstate=disable iommu=pt amd_iommu=on
Build Date: 14 February 2022  01:50:59PM
Build ID: xorg-x11-server 1.20.4-17.tl2 
Current version of pixman: 0.34.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Wed Aug 17 00:01:10 2022
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE) 
Fatal server error:
(EE) no screens found(EE) 
(EE) 
Please consult the The X.Org Foundation support 
at http://wiki.x.org
for help. 
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图5
尝试强制启动 X Window,依旧报错

startx -w

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图6
执行

init 3

可以显示命令模式,但是顶部出现一些异常的字符串
执行

init 5

和上面安装GUI重启后一样的黑屏,不显示任何内容。
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图4
根据 startx 命令启动后的报错提示得知
问题主要在于

(EE) 
Fatal server error:
(EE) no screens found(EE)

打印 xorg 日志

[  3063.444] 
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
[  3063.444] Build Operating System:  4.14.105-19-0006 
[  3063.444] Current Operating System: Linux VM-16-7-centos 5.4.119-19-0009.3 #1 SMP Wed Apr 20 22:27:43 CST 2022 x86_64
[  3063.444] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.119-19-0009.3 root=UUID=962910d5-ec2c-4f21-b0e9-eb2307916c9e ro quiet elevator=noop console=ttyS0,115200 console=tty0 vconsole.keymap=us crashkernel=1800M-64G:256M,64G-128G:512M,128G-:768M vconsole.font=latarcyrheb-sun16 net.ifnames=0 biosdevname=0 intel_idle.max_cstate=1 intel_pstate=disable iommu=pt amd_iommu=on
[  3063.444] Build Date: 14 February 2022  01:50:59PM
[  3063.444] Build ID: xorg-x11-server 1.20.4-17.tl2 
[  3063.444] Current version of pixman: 0.34.0
[  3063.444]    Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
[  3063.445] Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  3063.445] (==) Log file: "/var/log/Xorg.0.log", Time: Wed Aug 17 00:43:53 2022
[  3063.445] (==) Using config directory: "/etc/X11/xorg.conf.d"
[  3063.445] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[  3063.445] (==) No Layout section.  Using the first Screen section.
[  3063.445] (==) No screen section available. Using defaults.
[  3063.445] (**) |-->Screen "Default Screen Section" (0)
[  3063.445] (**) |   |-->Monitor "<default monitor>"
[  3063.445] (==) No monitor specified for screen "Default Screen Section".
Using a default monitor configuration.
[  3063.445] (==) Automatically adding devices
[  3063.445] (==) Automatically enabling devices
[  3063.445] (==) Automatically adding GPU devices
[  3063.445] (==) Automatically binding GPU devices
[  3063.445] (==) Max clients allowed: 256, resource mask: 0x1fffff
[  3063.445] (==) FontPath set to:
catalogue:/etc/X11/fontpath.d,
built-ins
[  3063.445] (==) ModulePath set to "/usr/lib64/xorg/modules"
[  3063.445] (II) The server relies on udev to provide the list of input devices.
If no devices become available, reconfigure udev or disable AutoAddDevices.
[  3063.445] (II) Loader magic: 0x559e6c68f020
[  3063.445] (II) Module ABI versions:
[  3063.445]    X.Org ANSI C Emulation: 0.4
[  3063.445]    X.Org Video Driver: 24.0
[  3063.445]    X.Org XInput driver : 24.1
[  3063.445]    X.Org Server Extension : 10.0
[  3063.450] (--) PCI:*([email protected]:2:0) 1013:00b8:1af4:1100 rev 0, Mem @ 0xf0000000/33554432, 0xfe424000/4096, BIOS @ 0x????????/131072
[  3063.450] (--) PCI: ([email protected]:8:0) 10de:1eb8:10de:12a2 rev 161, Mem @ 0xfd000000/16777216, 0xe0000000/268435456, 0xf2000000/33554432, BIOS @ 0x????????/65536
[  3063.450] (II) LoadModule: "glx"
[  3063.450] (II) Loading /usr/lib64/xorg/modules/extensions/libglx.so
[  3063.451] (II) Module glx: vendor="X.Org Foundation"
[  3063.451]    compiled for 1.20.4, module version = 1.0.0
[  3063.451]    ABI class: X.Org Server Extension, version 10.0
[  3063.451] (==) Matched modesetting as autoconfigured driver 0
[  3063.451] (==) Matched fbdev as autoconfigured driver 1
[  3063.451] (==) Matched vesa as autoconfigured driver 2
[  3063.451] (==) Assigned the driver to the xf86ConfigLayout
[  3063.451] (II) LoadModule: "modesetting"
[  3063.451] (II) Loading /usr/lib64/xorg/modules/drivers/modesetting_drv.so
[  3063.451] (II) Module modesetting: vendor="X.Org Foundation"
[  3063.451]    compiled for 1.20.4, module version = 1.20.4
[  3063.451]    Module class: X.Org Video Driver
[  3063.451]    ABI class: X.Org Video Driver, version 24.0
[  3063.451] (II) LoadModule: "fbdev"
[  3063.451] (II) Loading /usr/lib64/xorg/modules/drivers/fbdev_drv.so
[  3063.451] (II) Module fbdev: vendor="X.Org Foundation"
[  3063.451]    compiled for 1.20.4, module version = 0.5.0
[  3063.451]    Module class: X.Org Video Driver
[  3063.451]    ABI class: X.Org Video Driver, version 24.0
[  3063.451] (II) LoadModule: "vesa"
[  3063.451] (II) Loading /usr/lib64/xorg/modules/drivers/vesa_drv.so
[  3063.451] (II) Module vesa: vendor="X.Org Foundation"
[  3063.451]    compiled for 1.20.1, module version = 2.4.0
[  3063.451]    Module class: X.Org Video Driver
[  3063.451]    ABI class: X.Org Video Driver, version 24.0
[  3063.451] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[  3063.451] (II) FBDEV: driver for framebuffer: fbdev
[  3063.451] (II) VESA: driver for VESA chipsets: vesa
[  3063.451] (--) using VT number 2
[  3063.480] (EE) open /dev/dri/card0: No such file or directory
[  3063.480] (WW) Falling back to old probe method for modesetting
[  3063.480] (EE) open /dev/dri/card0: No such file or directory
[  3063.480] (II) Loading sub module "fbdevhw"
[  3063.481] (II) LoadModule: "fbdevhw"
[  3063.481] (II) Loading /usr/lib64/xorg/modules/libfbdevhw.so
[  3063.481] (II) Module fbdevhw: vendor="X.Org Foundation"
[  3063.481]    compiled for 1.20.4, module version = 0.0.2
[  3063.481]    ABI class: X.Org Video Driver, version 24.0
[  3063.481] (EE) Unable to find a valid framebuffer device
[  3063.481] (WW) Falling back to old probe method for fbdev
[  3063.481] (II) Loading sub module "fbdevhw"
[  3063.481] (II) LoadModule: "fbdevhw"
[  3063.481] (II) Loading /usr/lib64/xorg/modules/libfbdevhw.so
[  3063.481] (II) Module fbdevhw: vendor="X.Org Foundation"
[  3063.481]    compiled for 1.20.4, module version = 0.0.2
[  3063.481]    ABI class: X.Org Video Driver, version 24.0
[  3063.481] (EE) open /dev/fb0: No such file or directory
[  3063.481] (EE) Screen 0 deleted because of no matching config section.
[  3063.481] (II) UnloadModule: "modesetting"
[  3063.481] (EE) Screen 0 deleted because of no matching config section.
[  3063.481] (II) UnloadModule: "fbdev"
[  3063.481] (II) UnloadSubModule: "fbdevhw"
[  3063.481] (II) Loading sub module "vbe"
[  3063.481] (II) LoadModule: "vbe"
[  3063.481] (II) Loading /usr/lib64/xorg/modules/libvbe.so
[  3063.481] (II) Module vbe: vendor="X.Org Foundation"
[  3063.481]    compiled for 1.20.4, module version = 1.1.0
[  3063.481]    ABI class: X.Org Video Driver, version 24.0
[  3063.481] (II) Loading sub module "int10"
[  3063.481] (II) LoadModule: "int10"
[  3063.481] (II) Loading /usr/lib64/xorg/modules/libint10.so
[  3063.481] (II) Module int10: vendor="X.Org Foundation"
[  3063.481]    compiled for 1.20.4, module version = 1.0.0
[  3063.481]    ABI class: X.Org Video Driver, version 24.0
[  3063.481] (II) VESA(0): initializing int10
[  3063.483] (II) VESA(0): Primary V_BIOS segment is: 0xc000
[  3063.483] (II) VESA(0): VESA BIOS detected
[  3063.483] (II) VESA(0): VESA VBE Version 3.0
[  3063.483] (II) VESA(0): VESA VBE Total Mem: 4096 kB
[  3063.483] (II) VESA(0): VESA VBE OEM: SeaBIOS VBE(C) 2011
[  3063.483] (II) VESA(0): VESA VBE OEM Software Rev: 0.0
[  3063.483] (II) VESA(0): VESA VBE OEM Vendor: SeaBIOS Developers
[  3063.483] (II) VESA(0): VESA VBE OEM Product: SeaBIOS VBE Adapter
[  3063.483] (II) VESA(0): VESA VBE OEM Product Rev: Rev. 1
[  3063.487] (EE) VESA(0): Specified fbbpp (24) is not a permitted value
[  3063.487] (II) UnloadModule: "vesa"
[  3063.487] (II) UnloadSubModule: "int10"
[  3063.487] (II) Unloading int10
[  3063.487] (II) UnloadSubModule: "vbe"
[  3063.487] (II) Unloading vbe
[  3063.487] (EE) Screen(s) found, but none have a usable configuration.
[  3063.487] (EE) 
Fatal server error:
[  3063.487] (EE) no screens found(EE) 
[  3063.488] (EE) 
Please consult the The X.Org Foundation support 
at http://wiki.x.org
for help. 
[  3063.488] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[  3063.488] (EE) 
[  3063.510] (EE) Server terminated with error (1). Closing log file.

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图7
问题主要出在 3063.487 至 3063.510 区间

[  3063.487] (EE) Screen(s) found, but none have a usable configuration.
[  3063.487] (EE) 
Fatal server error:
[  3063.487] (EE) no screens found(EE) 
[  3063.488] (EE) 
Please consult the The X.Org Foundation support 
at http://wiki.x.org
for help. 
[  3063.488] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[  3063.488] (EE) 
[  3063.510] (EE) Server terminated with error (1). Closing log file.

说这么多主要是给大家一个思路,如果实在想使用GUI又不想装VNC,可以通过以上日志搜索百度 and 谷歌寻找解决方法。
不多说,开始安装 VNC

2.0 VNC Server 安装

执行下方命令安装 VNC Server 软件包

yum install tigervnc-server -y

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图8

2.1 复制 VNC Server 服务配置模板

cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service

2.1 配置 VNC 密码

此处的密码并非 SSH 密码,是单独连接 VNC 服务的密码,建议设置为复杂密码。
执行命令后输入密码   确认密码,Would you like to enter a view-only password 一定要选择 n,否则可能无法连接 VNC 服务。

vncpasswd

腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图9

2.3 启动 VNC 服务

systemctl start [email protected]:1 #启用 vnc server 
systemctl enable [email protected]:1 #开启自启 vnc server

2.4 下载VNC Viewer

进入 VNC VIewer 下载地址,地址:https://www.realvnc.com/en/connect/download/viewer/
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图10
安装一直下一步即可,软件安装步骤跳过.

2.5  开放服务器安全组

服务器安全组开放 5901 端口即可,如果在生产环境,考虑到安全问题,一定要设置来源 IP 为自己当前的 IP(后期 IP 变化需要同步更改)或连接 VNC 服务电脑的 IP,避免被恶意爆破。
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图11

2.6  通过软件连接 VNC

VNC Server 输入 IP:5901
name 输入 root 或管理员用户名即可。
双击新建的桌面即可连接。
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图12
可能会报错提示:The connection was refused by the computer
执行

vncserver

重新初始化 vnc 服务即可。
重新连接。
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图13
忽略上方提示即可,直接点击 continue 连接。
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图14
输入密码点击 OK 即可成功连接!
腾讯云服务器 centos7、8 安装 GUI(图形化界面)+安装 VNC Server 通过 VNC Viewer 远程连接 VNC 桌面插图15
连接成功!剩下的设置根据自己的需求选择即可。
温馨提示:某些系统会无法通过网页端 VNC 控制台连接,如果外网 IP 无法访问(被 DDOS 或其他因素导致无法访问)且是在腾讯云、阿里云的服务器出现这种情况
建议在当前服务器的账号购买一台同地域、同可用区的竞价实例服务器(最低配置每小时约 0.04 元),可以通过云服务商提供的内网 IP 连接。
进行临时运营维护,避免业务出现问题。

「点点赞赏,手留余香」

还没有人赞赏,快来当第一个赞赏的人吧!

阿峰博客给阿峰博客打赏
×
予人玫瑰,手有余香
  • 1
  • 5
  • 10
  • 20
  • 50
1
支付

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

2022-10-31

2022-10-31

发表评论

本站已严格贯彻落实《互联网跟帖评论服务管理规定》 注册账号需绑定并验证手机号真实性
  • 您可享受35%的返佣现金哦~