news 2026/10/17 6:04:59

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/17 8:52:26

minio分片上传

minio分片上传前言分片上传的技术选择实现分片上传第一步自定义客户端初始化分片上传获取一个上传分片的url共前端使用确认每一个分片的上传合并分片文件前言 为什么要选择将一个大文件拆分成许多小文件来上传&#xff1f; 对于许多服务器和应用框架来说&#xff0c;单次HTTP…

作者头像 李华
网站建设 2026/10/16 10:53:09

基于MATLAB实现深度学习图像分类

一、环境配置与数据准备 1.1 环境要求 MATLAB版本&#xff1a;R2021a及以上&#xff08;需安装Deep Learning Toolbox&#xff09;GPU支持&#xff1a;推荐NVIDIA CUDA兼容显卡&#xff08;通过gpuDevice验证&#xff09; 1.2 数据组织结构 dataset/ ├── train/ │ ├──…

作者头像 李华
网站建设 2026/10/15 19:51:02

9、UNIX/Linux 文件操作全解析

UNIX/Linux 文件操作全解析 1. 文件内容的初步探索 当你尝试使用 cat 命令查看文件内容时,可能会遇到权限问题,例如: $ cat myfile cat: myfile: Permission denied若已知文件存在,我们自然会想知道它的内容。虽然文件本质是字节序列,但我们更关心这些字节代表什么。…

作者头像 李华
网站建设 2026/10/16 21:38:52

企业SRC支付漏洞EDUSRC众测挖掘思路技巧操作分享

0x1 前言这篇文章也是给师傅们分享几个SRC漏洞挖掘中的技巧点&#xff0c;两个企业SRC漏洞案例&#xff0c;支付漏洞中&#xff0c;师傅们碰到都可以进行尝试验证下&#xff0c;要是挖到了&#xff0c;像众测中就是中、高危起步了。赏金的价格还不错&#xff0c;两个案例也写的…

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

webpack输出代码报错到指定文本文件

文章目录 概述代码 概述 在vscode的控制台输出的报错是有限的&#xff0c;多了就看不全了。想要看全部代码报错&#xff0c;就产生了如下方式&#xff1a; 代码 // 在package.json的scripts下&#xff0c;增加以下配置&#xff1a; start2: "set NO_COLOR1 && …

作者头像 李华
网站建设 2026/10/16 15:35:43

自然语言处理容易混淆知识点(二)BERT和BERTopic的区别

BERT和BERTopicBERT&#xff08;深度学习模型&#xff09;BERTopic&#xff08;主题建模工具包&#xff09;关系类比详细对比1. BERT&#xff1a;基础组件2. BERTopic&#xff1a;完整系统技术架构图关键区别表格实际代码对比**只用 BERT**使用 BERTopic常见混淆点澄清1. 名字为…

作者头像 李华