news 2026/10/24 1:28:30

webvm 用浏览器启动的虚拟环境

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
webvm 用浏览器启动的虚拟环境

WebVM是一款基于WebAssembly技术的浏览器虚拟机,可直接在浏览器中运行完整的Linux环境,无需服务器支持

源码:https://github.com/leaningtech/webvm/

github部署

安装介绍:

动手实践:

打开网站:https://github.com/leaningtech/webvm

fork到自己的github账户:

直接点setting:

在setting页面,点击pages:

在Pages展开的右边页面,打开Build and deployment下面的GitHub ACtions,选Deploy from a branch:

可以看到把main映射到根目录了:

然后点Action:

出现Workflows页面,点绿色的大按钮:

出现Actions页面,点左侧的Deploy按钮:

点右侧的Run workflow,然后点绿色按钮:Run workflow

后面就是慢慢等待发布成功:

但是不知道为何,我这边发布是失败的。

本地部署

下载源码

git clone https://github.com/leaningtech/webvm.git cd webvm

下载Debian mini 镜像

wget "https://github.com/leaningtech/webvm/releases/download/ext2_image/debian_mini_20230519_5022088024.ext2"

修改配置文件

Edit `config_public_terminal.js` to reference your local disk image:

  • Replace:

    "wss://disks.webvm.io/debian_large_20230522_5044875331.ext2"

    With:

    "/disk-images/debian_mini_20230519_5022088024.ext2"

    (Use an absolute or relative URL pointing to the disk image location.)

  • Replace"cloud"with the correct disk image type:"bytes"

最终修改成这样

// The root filesystem location // export const diskImageUrl = "wss://disks.webvm.io/debian_large_20230522_5044875331_2.ext2"; export const diskImageUrl = "debian_large_20230522_5044875331_2.ext2"; // The root filesystem backend type // export const diskImageType = "cloud"; export const diskImageType = "bytes";

build

npm install npm run build

实战中我是使用了pnpm

pnpm install pnpm run build

build完成提示:

[vite-plugin-static-copy] Copied 6 items. ✓ built in 32.50s Run npm run preview to preview your production build locally. > Using @sveltejs/adapter-static Wrote site to "build" ✔ done

配置nginx

mkdir disk-images mv debian_mini_20230519_5022088024.ext2 disk-images/

修改nginx.conf文件,加入:

​ location /disk-images/ { root .; autoindex on; } ​

启动nginx

sudo nginx -p . -c nginx.conf

出来页面了

尽管只是个黑黑的控制台,也很棒了!

不过后面有报错,没搞定。

调试

pnpm run build报错

> webvm@2.0.0 build
> vite build

vite v5.4.21 building SSR bundle for production...
✓ 31 modules transformed.
x Build failed in 1.06s
error during build:
config_public_terminal.js (2:9): Expected ';', '}' or <eof>
file: config_public_terminal.js:2:9

1: // The root filesystem location
2: # export const diskImageUrl = "wss://disks.webvm.io/debian_large_20230522_5044875331_2.ext2";
^
3: export const diskImageUrl = "debian_large_20230522_5044875331_2.ext2";
4: // The root filesystem backend type

at getRollupError (file:///home/skywalk/github/webvm/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
at ParseError.initialise (file:///home/skywalk/github/webvm/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:14469:28)
at convertNode (file:///home/skywalk/github/webvm/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16352:10)
at convertProgram (file:///home/skywalk/github/webvm/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15592:12)
at Module.setSource (file:///home/skywalk/github/webvm/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17352:24)
at async ModuleLoader.addModuleSource (file:///home/skywalk/github/webvm/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:21377:13)

发现是注释用错了,不应该用#,要用//

// The root filesystem location // export const diskImageUrl = "wss://disks.webvm.io/debian_large_20230522_5044875331_2.ext2"; export const diskImageUrl = "debian_large_20230522_5044875331_2.ext2"; // The root filesystem backend type // export const diskImageType = "cloud"; export const diskImageType = "bytes";

build完成

这段代码应该放到nginx的哪里?

location /disk-images/ { root .; autoindex on; }

放到主文件的location / 后面或前面

webvm启动报错

curl --max-time 15 parrot.live # requires networking

WebVM encountered an unexpected error

Check the DevTools console for further information

Please consider reporting a bug!

CheerpX internal error message is:

Initialization failed for 'HttpBytesDevice': Server returned 404
不知道为啥啊!是不是国内网络的锅啊?

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/10/22 2:26:01

Github-Lobe Chat:下一代开源AI聊天框架,重新定义人机交互体验

Github-Lobe Chat&#xff1a;下一代开源AI聊天框架&#xff0c;重新定义人机交互体验https://github.com/lobehub/lobe-chat&#x1f4cb; 项目概览Lobe Chat 是一个现代化的开源AI聊天界面框架&#xff0c;支持一键免费部署私有化的OpenAI ChatGPT/Claude/Gemini/Groq/Ollama…

作者头像 李华
网站建设 2026/10/23 8:31:21

11、UNIX与Linux编程基础:进程、环境与程序控制

UNIX与Linux编程基础:进程、环境与程序控制 1. 信号机制 在UNIX系统中,内核掌控着众多由不同用户创建的进程,其中包含许多维持系统正常运行所必需的“系统”进程。为了实现进程间的通信,内核允许进程之间相互发送“消息”。不过,由于系统中可能同时存在大量进程和消息,…

作者头像 李华
网站建设 2026/10/24 1:26:25

24、Perl编程入门:基础、应用与最佳实践

Perl编程入门:基础、应用与最佳实践 1. 读取密码文件中的用户名 在某些场景下,我们需要从系统的 /etc/passwd 文件中提取所有用户名。该文件以冒号分隔各个字段,第一个字段即为用户名。以下是一个使用 Perl 实现的脚本: open(PASSWORDS, "/etc/passwd"); wh…

作者头像 李华
网站建设 2026/10/22 1:13:22

UG高版本多轴联动开粗分享—东莞振华职校

UG 高版本&#xff08;如 NX1899 及以后&#xff09;新增了更智能的多轴动态开粗功能&#xff0c;能通过侧刃高效切削&#xff0c;还可灵活适配四轴、五轴加工场景&#xff0c;大幅提升复杂工件开粗效率。下面从核心操作流程、关键参数设置、优化技巧和避坑要点四方面展开分享&…

作者头像 李华
网站建设 2026/10/23 4:33:08

10BASE-T1S以太网技术实践:基于Microchip方案实现单对线50节点工业网络

文章目录1. 10BASE-T1S技术概述1.1 技术背景与发展1.2 技术特点与优势1.3 工业应用场景2. 系统架构设计2.1 整体网络架构2.2 硬件选型分析2.3 软件架构设计3. 开发环境搭建3.1 硬件开发环境3.2 软件开发环境3.3 测试工具准备4. 硬件设计与实现4.1 原理图设计4.2 PCB布局要点4.3…

作者头像 李华
网站建设 2026/10/23 15:55:41

5路红外循迹小车

所需模块&#xff1a;1.stm32f103c8t6核心板2.TB6612电机驱动模块1个3.5个红外循迹传感器4.4个电机通过左右电机产生差速来控制方向main.c#include "system.h" #include "stm32f10x.h" #include "SysTick.h" #include "motor.h" #incl…

作者头像 李华