当前位置: 首页 > java >正文

服务器安装xfce桌面环境并通过浏览器操控

最近需要运行某个浏览器的脚本,但是服务器没有桌面环境,无法使用,遂找到了KasmVNC,并配合xfce实现低占用的桌面环境,可以直接使用浏览器进行操作

本文基于雨云——新一代云服务提供商的Debian11服务器操作,NAT网络服务器实惠不限流量,有兴趣可以去看看。
另外欢迎来我的博客:火柴人儿的小站

安装KasmVNC

这里的步骤基于此教程在Ubuntu上安装KasmVNC实现轻松远程桌面访问 - 自由码农
建议都使用root用户操作,若非root用户,部分命令前需要加sudo 才可生效

  1. 下载KasmVNC

    检查系统版本

    lsb_release -a
    

    image-20250520142757935

    检查系统架构

    uname -m
    

    image-20250520142813017

    可以看到,我的是Debian11,bullseye是这个版本的代号,x86_64就是64位,那么根据这两个信息,就可以在项目发布页找到自己所需的版本进行下载,为方便取用,我这里留一个网盘的下载链接

    • kasmvncserver_bullseye_1.3.4_amd64.deb

    image-20250520143603468

    下载下来的文件上传到服务器得/home目录下

  2. 配置apt源

    选择其一即可

    • 腾讯云镜像源

      cat <<'EOF' > /etc/apt/sources.list
      # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
      deb https://mirrors.tencent.com/debian/ bullseye main contrib non-free
      # deb-src https://mirrors.tencent.com/debian/ bullseye main contrib non-freedeb https://mirrors.tencent.com/debian/ bullseye-updates main contrib non-free
      # deb-src https://mirrors.tencent.com/debian/ bullseye-updates main contrib non-freedeb https://mirrors.tencent.com/debian/ bullseye-backports main contrib non-free
      # deb-src https://mirrors.tencent.com/debian/ bullseye-backports main contrib non-free# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
      # 一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟
      # deb https://mirrors.tencent.com/debian-security bullseye-security main contrib non-free
      # # deb-src https://mirrors.tencent.com/debian-security bullseye-security main contrib non-freedeb https://security.debian.org/debian-security bullseye-security main contrib non-free
      # deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free
      EOF
      
      apt-get update  #更新
      
    • 中科大镜像源

      cat <<'EOF' > /etc/apt/sources.list
      # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
      deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
      # deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-freedeb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
      # deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-freedeb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
      # deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
      # 一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟
      # deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
      # # deb-src https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-freedeb https://security.debian.org/debian-security bullseye-security main contrib non-free
      # deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free
      EOF
      
      apt-get update  #更新
      
    • 阿里云镜像源

      cat <<'EOF' > /etc/apt/sources.list
      # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
      deb https://mirrors.aliyun.com/debian/ bullseye main contrib non-free
      # deb-src https://mirrors.aliyun.com/debian/ bullseye main contrib non-freedeb https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-free
      # deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-freedeb https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-free
      # deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-free# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
      # 一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟
      # deb https://mirrors.aliyun.com/debian-security bullseye-security main contrib non-free
      # # deb-src https://mirrors.aliyun.com/debian-security bullseye-security main contrib non-freedeb https://security.debian.org/debian-security bullseye-security main contrib non-free
      # deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free
      EOF
      
      apt-get update  #更新
      
  3. 安装KasmVNC

    cd /home
    dpkg -i kasmvncserver_bullseye_1.3.4_amd64.deb
    

    出现依赖问题

    image-20250520150226595

    安装依赖

    apt --fix-broken install
    

    安装完成后查看KasmVNC版本,显示出版本号即安装成功

    dpkg -s kasmvncserver | grep Version
    

    image-20250520151753653

  4. 初始化 KasmVNC 配置

    kasmvncserver
    

    image-20250520152422080

  5. 放行8444端口,将内部的8444映射到外网的18444(可随意设置)

    image-20250520152551842

  6. 通过https://ip:18444访问(必须使用https访问

    点击高级➡️继续访问

    image-20250520152902855

    输入用户名和密码

    image-20250520152956756

    登录进去之后,现在是黑屏,是正常情况,我们还需要配置一个桌面环境,教程中使用的是GNOME,它占用资源比较大,所以我改为使用XFCE

    此外,如果浏览器左上角提示是否允许读取剪贴板,一定要点允许,不然键盘无法输入命令。

  7. 配置桌面环境

    安装xfce桌面环境,时间可能比较长,耐心等待

    apt install xfce4 dbus-x11 dbus-user-session -y
    

    安装过程中会弹出以下选择界面,选择第一个,然后点击tab键,回车即可

    image-20250520160735417

    编辑配置文件

    cat << EOF > ~/.vnc/xstartup 
    #!/bin/bash
    set -x exec 
    xfce4-session 
    EOF
    

    设置执行权限

    chmod +x ~/.vnc/xstartup
    

    重启vnc服务

    vncserver -kill :1   #停止当前会话
    vncserver  #启动一个新的会话
    

    image-20250520162624414

  8. 刷新页面

    image-20250520110051599

安装火狐浏览器

安装好桌面环境之后立马内置的浏览器无法使用,使用apt安装火狐我也试了,Mozilla APT 库下载总是失败,结果发现直接下载安装包解压就能用了😂

  1. 去[官网](下载适用于 Linux 的 Mozilla Firefox — 快速、私密且免费 Mozilla 出品)下载所需安装包,默认是32位,需要自己选择64位的,这个应该都能下载,不过我还是留一个下载链接吧:firefox-138.0.4.tar.xz

    image-20250521091743448

    image-20250521091759893

  2. 并上传到服务器/home目录下,我这里使用的是WindTerm

    image-20250521091917427

  3. 解压安装包

    cd /home
    tar Jxf firefox-138.0.4.tar.xz  # 这里的J一定要大写 
    
  4. 运行firefox

    解压完成后,在解压文件内找到firefox,双机即可打开浏览器

    image-20250521092430868

    image-20250521093108656

解决中文乱码

可以看到上图的浏览器中,中文都是乱码,这是因为没有安装显示中文的字体,只需要安装一个中文字体即可

apt install fonts-noto-cjk

安装完成后,刷新浏览器即可

image-20250521093351312

http://www.xdnf.cn/news/7787.html

相关文章:

  • SpringBoot外部化配置
  • NIFI的处理器:ExecuteGroovyScript 2.4.0
  • 第14天-Matplotlib实现数据可视化
  • ollama使用gpu运行大模型
  • Xilinx 7Series\UltraScale 在线升级FLASH STARTUPE2和STARTUPE3使用
  • Java 定时任务中Cron 表达式与固定频率调度的区别及使用场景
  • 唯创安全优化纸业车间安全环境:门口盲区预警报警器的应用与成效
  • STL中的Vector(顺序表)
  • RabbitMQ——消息确认
  • NLP学习路线图(三): 微积分(梯度、导数等)
  • 有没有其他影视app可以像群晖video station一样可以被Windows的本地网络驱动器找到
  • 【Vue3】数据的返回和响应式处理(ref reactive)
  • 自建srs实时视频服务器支持RTMP推流和拉流
  • Kotlin 极简小抄 P8(不可空类型、可空类型、注意事项、非空断言 !!)
  • 什么是endpoints?
  • php://filter的trick
  • Server-Driven UI:Kotlin 如何重塑动态化 Android 应用开发
  • 《算法笔记》12.1小节——字符串专题->字符串hash进阶 问题 A: 求最长公共子串(串)
  • 代码随想录打卡|Day45 图论(孤岛的总面积 、沉没孤岛、水流问题、建造最大岛屿)
  • ARM反汇编浅析
  • 【JAVA】比较器Comparator与自然排序(28)
  • Flannel后端为UDP模式下,分析数据包的发送方式(一)
  • 【react18】在styled-components中引入图片报错
  • 项目中Warmup耗时高该如何操作处理
  • 深度解析 Java 中介者模式:重构复杂交互场景的优雅方案
  • 详解 C# 中基于发布-订阅模式的 Messenger 消息传递机制:Messenger.Default.Send/Register
  • 服务器网络配置 netplan一个网口配置两个ip(双ip、辅助ip、别名IP别名)
  • Java详解LeetCode 热题 100(18):LeetCode 73. 矩阵置零(Set Matrix Zeroes)详解
  • 广州卓远VR受邀参加2025智能体育典型案例调研活动,并入驻国体华为运动健康联合实验室!
  • 深入解析异步编程:Java NIO、Python `async/await` 与 C# `async/await` 的对比