在小VPS上安装了远程桌面,记录下过程。
Debian 13 轻量桌面环境 + Chrome 安装部署文档
1. 环境信息
本次部署环境如下:
系统:Debian GNU/Linux 13
内核:Linux funart.com.hk 6.12.38+deb13-amd64
架构:x86_64
内存:4G
目标:安装轻量桌面环境,并安装 Google Chrome,用于远程图形化操作2. 推荐方案
推荐采用:
XFCE 最小化桌面环境 + xrdp 远程桌面 + Google Chrome Stable + 2G swap推荐理由
- XFCE 轻量稳定,适合 4G 内存 VPS 或服务器。
- 相比 GNOME/KDE,占用资源更低。
xrdp可以直接使用 Windows/macOS 远程桌面客户端连接。- Google Chrome Stable 兼容性较好,适合网页后台、管理页面、浏览器测试等场景。
- 增加 2G swap 后,在 Chrome 打开多个页面时更稳。
3. 更新系统基础环境
切换到 root:
sudo -i更新系统:
apt update
apt upgrade -y安装基础工具:
apt install -y sudo curl wget gnupg ca-certificates apt-transport-https4. 创建普通桌面用户
不建议使用 root 运行 Chrome,因此创建普通用户:
adduser liang
usermod -aG sudo liang说明:
liang是远程桌面登录用户。usermod -aG sudo liang表示授予 sudo 权限。- 后续远程桌面登录建议使用该普通用户。
5. 安装轻量 XFCE 桌面环境
推荐最小化安装,避免装入过多不必要组件:
apt install -y --no-install-recommends \
xorg \
dbus-x11 \
xfce4 \
xfce4-terminal \
thunar \
mousepad \
fonts-noto-cjk \
fonts-wqy-zenhei组件说明:
| 组件 | 作用 |
|---|---|
xorg | X11 图形环境基础 |
dbus-x11 | 桌面会话通信组件 |
xfce4 | XFCE 桌面环境 |
xfce4-terminal | XFCE 终端 |
thunar | XFCE 文件管理器 |
mousepad | 轻量文本编辑器 |
fonts-noto-cjk | 中日韩字体支持 |
fonts-wqy-zenhei | 中文字体支持 |
如希望桌面功能更完整,可选择:
apt install -y xfce4 xfce4-goodies lightdm但在 4G 内存服务器上,更推荐前面的最小化方案。
6. 安装 xrdp 远程桌面服务
安装:
apt install -y xrdp xorgxrdp设置开机启动并立即启动:
systemctl enable xrdp
systemctl start xrdp将 xrdp 用户加入 ssl-cert 组:
adduser xrdp ssl-cert
systemctl restart xrdp7. 指定用户默认进入 XFCE 桌面
给普通用户设置默认图形会话:
su - liang
echo "startxfce4" > ~/.xsession
chmod +x ~/.xsession
exit也可以用一条命令完成:
su - liang -c 'echo "startxfce4" > ~/.xsession && chmod +x ~/.xsession'检查 xrdp 服务状态:
systemctl status xrdp --no-pager检查 3389 端口监听:
ss -lntp | grep 33898. 远程桌面连接方式
使用 Windows 远程桌面或 macOS Microsoft Remote Desktop 连接:
地址:服务器IP:3389
用户名:liang
密码:创建 liang 用户时设置的密码登录后应进入 XFCE 桌面。
9. 防火墙安全建议
如果服务器开启了 ufw,可以安装并配置:
apt install -y ufw放行 SSH:
ufw allow OpenSSH推荐只允许自己的公网 IP 访问远程桌面端口:
ufw allow from 你的公网IP to any port 3389 proto tcp启用防火墙:
ufw enable临时测试时也可以直接放行 3389:
ufw allow 3389/tcp但不建议长期全网开放 3389 端口。
更安全的方式:
- 只允许固定 IP 访问 3389。
- 或使用 SSH 隧道访问 xrdp。
- 或将 3389 放在内网/VPN 后面。
10. 安装 Google Chrome Stable
创建 keyrings 目录:
install -d -m 0755 /etc/apt/keyrings导入 Google Linux signing key:
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /etc/apt/keyrings/google-linux-signing-key.gpg添加 Chrome 软件源:
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-linux-signing-key.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list更新软件源并安装 Chrome:
apt update
apt install -y google-chrome-stable验证版本:
google-chrome --version11. Chrome 运行建议
进入远程桌面后,使用普通用户启动 Chrome:
google-chrome如果是 VPS,没有 GPU,建议使用:
google-chrome --disable-gpu --disable-dev-shm-usage不要使用 root 运行 Chrome。
不建议长期使用:
google-chrome --no-sandbox--no-sandbox 会降低浏览器安全性,只建议临时排错时使用。
12. 配置 2G swap
4G 内存运行 XFCE + Chrome 基本够用,但为了避免 Chrome 页面多时内存不足,建议增加 2G swap。
创建 swap 文件:
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile设置开机自动挂载:
echo '/swapfile none swap sw 0 0' >> /etc/fstab调整 swappiness:
echo 'vm.swappiness=20' > /etc/sysctl.d/99-swappiness.conf
sysctl -p /etc/sysctl.d/99-swappiness.conf查看 swap 状态:
free -h
swapon --show13. 一键汇总命令
以下为完整汇总命令,可作为部署记录保存:
sudo -i
apt update
apt upgrade -y
apt install -y sudo curl wget gnupg ca-certificates apt-transport-https
adduser liang
usermod -aG sudo liang
apt install -y --no-install-recommends \
xorg \
dbus-x11 \
xfce4 \
xfce4-terminal \
thunar \
mousepad \
fonts-noto-cjk \
fonts-wqy-zenhei
apt install -y xrdp xorgxrdp
systemctl enable xrdp
systemctl start xrdp
adduser xrdp ssl-cert
su - liang -c 'echo "startxfce4" > ~/.xsession && chmod +x ~/.xsession'
install -d -m 0755 /etc/apt/keyrings
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /etc/apt/keyrings/google-linux-signing-key.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-linux-signing-key.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list
apt update
apt install -y google-chrome-stable
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
echo 'vm.swappiness=20' > /etc/sysctl.d/99-swappiness.conf
sysctl -p /etc/sysctl.d/99-swappiness.conf
systemctl restart xrdp14. 常见排错
14.1 远程桌面连接后黑屏
检查用户的 .xsession:
cat /home/liang/.xsession应为:
startxfce4重新赋权:
chown liang:liang /home/liang/.xsession
chmod +x /home/liang/.xsession重启 xrdp:
systemctl restart xrdp14.2 3389 端口没有监听
检查服务:
systemctl status xrdp --no-pager重启:
systemctl restart xrdp查看监听:
ss -lntp | grep 338914.3 Chrome 无法启动
使用普通用户执行:
google-chrome --disable-gpu --disable-dev-shm-usage确认不要用 root 直接运行 Chrome。
14.4 中文显示异常
确认已安装中文字体:
apt install -y fonts-noto-cjk fonts-wqy-zenhei刷新字体缓存:
fc-cache -fv15. 最终推荐结论
当前机器为 4G 内存 Debian 13 服务器,推荐部署方案为:
XFCE 最小化桌面 + xrdp + Google Chrome Stable + 2G swap该方案资源占用低、远程连接方便、兼容性好,适合用于服务器上的轻量图形化操作、浏览器后台访问、网页管理和简单办公操作。