服务器Ubuntu22.04 server 安装gnome GUI+VNC远程配置

服务器端配置


一、安装桌面环境:

1.更新软件源。
复制代码
sudo apt update
2.安装桌面环境所需的软件包,包括系统面板、窗口管理器、文件浏览器、终端等桌面应用程序。
复制代码
sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop

二、配置VNC服务器:

3.安装 TightVNC 服务器
复制代码
sudo apt install tightvncserver
4.通过 vncserver 命令启动 VNC 服务器实例,第一次运行时同时会完成初始化(设置 VNC 访问密码,创建初始配置文件)
复制代码
vncserver
5.系统将提示输入并验证密码以远程访问您的机器

6.验证密码后,可以选择创建仅供查看的密码。使用仅查看密码登录的用户将无法使用鼠标或键盘控制 VNC 实例,没有演示需要的输入 n 即可,后续如有需要可以再设置。

三、配置 xstartup 配置文件

7.备份VNC的xstartup配置文件
复制代码
cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
8.修改VNC的xstartup配置文件
复制代码
nano ~/.vnc/xstartup

复制以下内容到文件:

复制代码
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME"
export XDG_MENU_PREFIX="gnome-flashback-"
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check
9.关闭VNC
复制代码
vncserver -kill :1
10.重新启动 VNC
复制代码
vncserver -geometry 1920x1080 :1 -localhost no

或不指定分辨率重启

复制代码
vncserver :1

客户端配置


11.在其他电脑使用RealVNC Viewer连接

可参考:Windows下通过VNC Viewer访问Linux服务器_vncviewer 服务端-CSDN博客

其他问题


一、灰屏或黑屏问题

查看日志文件寻找问题2:

复制代码
cat /home/xmu18-tc/.vnc/xmu18:1.log

出现内容如下:

08/03/25 08:06:04 Xvnc version TightVNC-1.3.10

08/03/25 08:06:04 Copyright (C) 2000-2009 TightVNC Group

08/03/25 08:06:04 Copyright (C) 1999 AT&T Laboratories Cambridge

08/03/25 08:06:04 All Rights Reserved.

08/03/25 08:06:04 See http://www.tightvnc.com/ for information on TightVNC

08/03/25 08:06:04 Desktop name 'X' (xmu18:1)

08/03/25 08:06:04 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t

08/03/25 08:06:04 Listening for VNC connections on TCP port 5901

Font directory '/usr/share/fonts/X11/Type1/' not found - ignoring

Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring

Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring

Terminated

提示没有字体,安装即可3,4:

复制代码
sudo apt-get update
sudo apt-get install -y xvfb    # 有时候会出现无法定位此包
sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-cyrillic xorg dbus-x11 xfonts-Type1

然后重新杀死VNC和开启VNC。

(/X11/Type1/' not found问题仍暂未找到解决方法...)

二、可能需要修改wayland问题

服务器上打开文件,取消wayland=false的注释5:

复制代码
sudo nano /etc/gdm3/custom.conf

重启生效

复制代码
sudo systemctl restart gdm3

(本人测试过,不修改此项因该也没什么问题;但是取消注释比不取消注释用起来流畅一些,可能是不同协议需要转换导致一些延迟..)


//参考连接:

1 https://linuxstory.org/how-to-install-and-configure-vnc-on-ubuntu-22-04/

2 https://cloud.tencent.com/developer/article/2387064

3 https://blog.csdn.net/lygzscnt12/article/details/108375183

4 https://github.com/GabrielBB/xvfb-action/issues/29

5 https://blog.csdn.net/yanchenyu365/article/details/133038162

相关推荐
未济3 天前
linux 配置环境变量
linux
傲世仙尊3 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.4 天前
进程间通信
linux
Liuqy-054 天前
Linux IO编程——静态库、动态库
linux
彧azz4 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅4 天前
linux(8) 软硬链接
linux·运维·服务器
Wang's Blog4 天前
Java 项目实战: 外卖平台-文件下载与ServletOutputStream回写浏览器
服务器·项目开发
AIgorithmGEEK4 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid
琥珀色糖4 天前
SimlpeHttp
linux·服务器