云网络系统(Cloud Computing)是一种通过互联网提供计算资源和服务的模式,允许用户在任何地方、任何时间访问和使用这些资源和服务。
云网络系统的主要特点包括:
- 按需自助服务:用户可以根据需要自行配置和管理计算资源。
- 广泛的网络访问:用户可以通过互联网从任何地方、任何时间访问云资源。
- 资源池化:云资源被池化和动态分配,以实现高效的资源利用。
- 快速弹性:云资源可以快速扩展或缩减,以适应不断变化的业务需求。
- 可测量的服务:云服务提供商可以根据用户的使用情况提供详细的计费和监控。
云网络系统puter官网star 29k:GitHub - HeyPuter/puter: 🌐 The Internet OS! Free, Open-Source, and Self-Hostable.
Puter 是一个先进的开源互联网操作系统,设计为功能丰富、速度极快且高度可扩展。Puter 可用作:
- 一个以隐私为优先的个人云,将所有文件、应用程序和游戏保存在一个安全的地方,随时随地可访问。
- 构建和发布网站、Web 应用程序和游戏的平台。
- Dropbox、Google Drive、OneDrive 等的替代品,具有全新的界面和强大的功能。
- 服务器和工作站的远程桌面环境。
- 一个友好的开源项目和社区,学习 Web 开发、云计算、分布式系统等更多内容!
安装
git clone https://github.com/HeyPuter/puter
cd puter
npm install
npm start
具体实践
nodejs版本升级
首先使用了Ubuntu24.04 ,但是碰到了npm install报错,见后面调试部分。
使用Ubuntu22.04,碰到npm没有安装的情况,安装:
sudo apt install npm
后来发现版本太低,于是手工安装了node.js22版本。
两种方法,源代码编译安装和二进制安装。
从头源代码安装
直接运行下面指令
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 22
# Verify the Node.js version:
node -v # Should print "v22.14.0".
nvm current # Should print "v22.14.0".
# Verify npm version:
npm -v # Should print "10.9.2".
整个编译过程需要半小时 。
直接下载二进制包安装
从官网下载安装包:Node.js — Download Node.js®
解压,
tar -xvf node-v22.14.0-linux-x64.tar.xz
比如解压到/home/xx/node-v22.14.0-linux-x64目录, 设定路径:
node -v
v12.22.9
export PATH=/home/xx/node-v22.14.0-linux-x64/bin:$PATH
node -v
v22.14.0
安装完成,整个过程只需要1分钟。
启动服务
cd puter
npm install
npm start
启动服务后,显示:
Puter is now live at: http://puter.localhost:4100 ┃
┃ Type web:dismiss to un-stick this message ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Your admin user has been created! ┃
┃ username: admin ┃
┃ password: b45642df ┃
┃ (change the password to remove this message) ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
浏览器打开 http://puter.localhost:4100
整个项目的配色还是非常舒服的
它还支持AI,不过暂时还没试出来。
添加服务(自建服务器不支持官方脚本)
可以在Dev Center开发中心添加服务,文档参考:Examples
比如在桌面写一个index.html文件,文件内容
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(`Why did the chicken cross the road?`).then(puter.print);
</script>
</body>
</html>
然后可以在Dev Center开发中心添加这个index.html文件,然后就可以用了。
不过没有调试成功,不知道是不是科学上网的问题,还是自己实在不懂node.js导致的。先搁置。
明白了,需要在官网才能使用提供的script服务:<script src="https://js.puter.com/v2/"></script>
自荐服务器目前还不支持。不过可以自己架设一个script服务器,让自己的服务器来使用。
总结
使用云网络系统puter的优点是:
可以快速开发,并且可以使用puter提供的js服务。
用户信息存储在puter服务器,省去了开发用户管理部分。
缺点:
如果使用puter服务器,则把用户信息等拱手让给了puter
puter向用户收费(比如AI调用额度、硬盘配额),这是双刃剑。
自建服务器的话无法使用puter提供的js服务(这样需要自己再建js服务)
如果自建js服务器,参考:FreeBSD下安装npm Node.js的22版本 并简单测试js服务器-CSDN博客
调试
npm install安装报错 stack Error: `gyp` failed with exit code: 1
npm ERR! During handling of the above exception, another exception occurred:
npm ERR!
npm ERR! Traceback (most recent call last):
npm ERR! File "/usr/share/nodejs/node-gyp/gyp/gyp_main.py", line 33, in <module>
npm ERR! sys.exit(load_entry_point('gyp==0.1', 'console_scripts', 'gyp')())
npm ERR! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! File "/usr/share/nodejs/node-gyp/gyp/gyp_main.py", line 22, in importlib_load_entry_point
npm ERR! for entry_point in distribution(dist_name).entry_points
npm ERR! ^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 862, in distribution
npm ERR! return Distribution.from_name(distribution_name)
npm ERR! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 399, in from_name
npm ERR! raise PackageNotFoundError(name)
npm ERR! importlib.metadata.PackageNotFoundError: No package metadata was found for gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/usr/share/nodejs/node-gyp/lib/configure.js:329:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:517:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12)
npm ERR! gyp ERR! System Linux 5.15.167.4-microsoft-standard-WSL2
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/share/nodejs/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /home/skywalk/github/puter/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v18.19.1
npm ERR! gyp ERR! node-gyp -v v9.3.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /home/skywalk/.npm/_logs/2025-03-10T14_33_42_318Z-debug-0.log
有时缺少某些构建工具或库会导致 gyp
报错。你可以通过以下方式来确保所有必要的依赖项都已安装:
sudo apt-get install build-essential
没解决,先搁置
报错Unable to locate package node
sudo apt install node
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
N: Ignoring file 'package-lock.json' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
E: Unable to locate package node
安装node.js试试
安好了也不行
怀疑是不是wsl 的ubuntu不支持?
不对啊,我明明是24.04,咋内核是:Linux version 5.15.167.4-microsoft-standard-WSL2 (root@f9c826d3017f) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP Tue Nov 5 00:21:55 UTC 2024
这内核有问题啊
ubuntu22的版本:Linux DESKTOP-9C5AU01 5.15.167.4-microsoft-standard-WSL2
node版本太低
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'lru-cache@11.0.2',
npm WARN EBADENGINE required: { node: '20 || >=22' },
npm WARN EBADENGINE current: { node: 'v18.19.1', npm: '9.2.0' }
尝试升级node.js
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 22
# Verify the Node.js version:
node -v # Should print "v22.14.0".
nvm current # Should print "v22.14.0".
# Verify npm version:
npm -v # Should print "10.9.2".
升级完成,报错问题解决。
npm install 安装报错npm error ENOTEMPTY: directory not empty, rename
npm install
npm error code ENOTEMPTY
npm error syscall rename
npm error path /home/skywalk/github/puter/node_modules/cpu-features
npm error dest /home/skywalk/github/puter/node_modules/.cpu-features-b4r1SrxE
npm error errno -39
npm error ENOTEMPTY: directory not empty, rename '/home/skywalk/github/puter/node_modules/cpu-features' -> '/home/skywalk/github/puter/node_modules/.cpu-features-b4r1SrxE'
npm error A complete log of this run can be found in: /home/skywalk/.npm/_logs/2025-03-11T04_13_04_717Z-debug-0.log
目录非空,清除目录
~/github/puter$ rm -rf node_modules/.cpu-features-b4r1SrxE/
问题解决。
创建的app没有执行
同样的在puter说明文档那里可以执行,但是在puter虚拟机里,创建了app,用这段代码,就没有响应
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
// Loading ...
puter.print(`Loading...`);
// Chat with GPT-4o mini
puter.ai.chat(`What is life?`).then(puter.print);
</script>
</body>
</html>
可能puter.ai.chat
调用的 API 有请求限制或需要身份验证