WSL2 图形化界面安装
windows端配置
VcXsrv
安装
这里我们需要安装 VcXsrv,可以直接在官方 github 仓库中进行下载:VcXsrv
配置
安装好之后直接启动:
选择界面
Multiple windows 是多窗口运行,就是把 WSL 中的应用作为一个窗口应用显示到 windows 系统上
Fullscreen 是全屏运行,如果选择这一项,建议新建一个桌面
One large window 是全屏窗口运行,在我们不使用的时候直接最小化即可
One window without titlebar 是窗口全屏话,这样便于我们切出,同时也去掉了标题栏
选择端口号
这里设置显示窗口编号,-1是自动从0分配
选择连接方式
这里就是要选择我们的连接方式,默认选择第一个就可以
禁用连接管理
这里我们要勾选第三项,WSL2 相当于是一个外部网络,所以我们要使用 ssh 进行连接
最后我们点击完成就可以了
WSL配置
安装 Ubuntu 桌面版
pre setup
根据CSDN博客在正式安装之前先输入以下命令,否则有概率安装失败。
apt purge -y acpid acpi-support modemmanager
apt-mark hold acpid acpi-support modemmanager
若没有以上命令,可能会在安装80%左右遇到这样的情况:
Setting up xxx(x.xx) ...
Failed to restart acpid.service: Transport endpoint is not connected
See system logs and 'systemctl status acpid.service' for details.
Failed to get properties: Transport endpoint is not connected
安装 Ubuntu 桌面版:
sudo apt install ubuntu-desktop
配置显示管理器
Ubuntu 桌面版默认使用 Gnome Display Manager (GDM) 作为显示管理器。由于 WSL2 不支持显示管理器,我们需要使用其他方法来启动桌面环境。
安装 Xfce4 桌面环境:
sudo apt install xfce4 xfce4-goodies
在 Ubuntu 终端中设置 DISPLAY 环境变量:
export DISPLAY=$(awk '/nameserver / {print$2; exit}' /etc/resolv.conf 2>/dev/null):0
使用sudo 启动 Xfce 会话:
sudo startxfce4
参考链接
https://www.bilibili.com/read/cv33557374/
https://blog.csdn.net/m0_59161987/article/details/129544000

浙公网安备 33010602011771号