服务器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

相关推荐
BetterNow.1 分钟前
安卓内存Previous为什么可以算进freeRam
android·linux·安卓·安卓性能·安卓内存
时空自由民.11 分钟前
ESP32 IDF HTTP OTA升级流程原理
linux·单片机
黄同学real15 分钟前
踩坑实录:离线内网服务器 Docker 部署 PaddleOCR-VL 1.5 完全指南
运维·服务器·docker
SilentSamsara15 分钟前
Python 并发基础:threading/GIL 与 multiprocessing 的选型逻辑
服务器·开发语言·数据库·vscode·python·pycharm
东北甜妹16 分钟前
K8s -Daemonset,kube-proxy,service,statefulset
linux·运维·服务器
Season45020 分钟前
论close()与signal(SIGPIPE,SIG_IGN)对服务器的重要性
运维·服务器
idolao20 分钟前
CentOS 7 安装 xampp-linux-1.8.1.tar.gz 详细步骤(解压、启动、验证)
linux·运维·centos
码点21 分钟前
Android 9休眠时任意键唤醒屏幕
android·linux·运维
杨云龙UP22 分钟前
Docker 部署 MongoDB 6.0 数据库每日自动备份实践:本地 + 异地保留 7 天_20260429
linux·运维·数据库·mongodb·docker·容器·centos
大袁同学38 分钟前
【进程间通信】:洞穿边界修管道,映射内存渡进程
linux·c++·管道·进程间通信·ipc