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

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
不知道为啥啊!是不是国内网络的锅啊?

http://www.jsqmd.com/news/92780/

相关文章:

  • STM32芯片程序读取方法总结
  • 16、UNIX和Linux实用技巧与操作指南
  • 同样做黑五,他凭效率赚翻倍?新常态玩法揭秘
  • 2026趋势展望:DSL模型能力将成为AI数据分析可用性的关键
  • 18、高级 shell 编程实用指南
  • 金属3D打印质量的重要性
  • Web 服务和 SFTP 用户 操作目录
  • 5、VXLAN与BGP EVPN的融合:数据中心网络的优化方案
  • GEO 3小问:一文搞懂 AI 搜索时代的 “品牌曝光关键”
  • Github-Lobe Chat:下一代开源AI聊天框架,重新定义人机交互体验
  • 19、高级Shell编程与正则表达式实用指南
  • GPT-5.2与Gemini 3.0 Pro深度对比及第三方API接入实践指南
  • 计算机网络体系结构核心知识点整理
  • GPT-5.2与Gemini 3.0 Pro技术选型指南:核心能力对比+第三方API接入全攻略
  • FastAPI 功能及工作流程详解
  • 20、UNIX 正则表达式与过滤器实用指南
  • Ubuntu安装及相关设置
  • 21、UNIX、Linux 与 Awk 使用指南
  • pythonstudy Day36
  • 智能图表生成:当数据分析从“怎么做图”变成“问什么”——某平台新工作流的技术解构与应用前瞻
  • 泛函分析与偏微分方程(三):弱拓扑、凸集与线性算子
  • 前端—CSS基础,零基础入门到精通,收藏这篇就够了
  • 2025年上海服务不错的书房全屋定制公司推荐,排名前几的全屋 - 工业品牌热点
  • 14、开源办公与网络应用全解析
  • edge浏览器无法打开惠普官网,但是那个chrome浏览器可以,为何?
  • 2025年五大靠谱恒温恒湿防爆冰箱供应商推荐,超低温立式防爆 - 工业推荐榜
  • ConnectUtility-罗技k275键盘鼠标套餐连接器-软件安装
  • 7款好用的降AI率工具,帮你把AI率从90%降到10%!
  • SRE 踩坑记:JVM 暂停竟然是因为日志
  • Python+Vue的大学生就业信息管理系统 Pycharm django flask