OpenClaw部署笔记:云服务器-npm方式部署(非使用腾讯云OpenClaw镜像系统部署)

OpenClaw部署笔记:云服务器-npm方式部署(非使用腾讯云OpenClaw镜像系统部署)

1.条件与环境

1.1 前提条件

1.2 本文运行环境

平台/软件 版本
腾讯云服务器 Ubuntu22.04-Docker26 26.1.3 2核/2GB 50GB SSD 4Mbps
本地操作系统 Windows 10

2.安装运行

2.1 安装node.js

注:不要使用apt install nodejs,因为这样安装的nodejs版本太低

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 1. 安装 nvm (使用国内源)
curl -o- https://gitee.com/mirrors/nvm/raw/master/install.sh | bash

# 2. 生效环境变量
source ~/.bashrc

# 3. 设置 Node 镜像(持久化)
echo 'export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/' >> ~/.bashrc
source ~/.bashrc

# 4. 安装 Node.js 24 LTS(稳定版本)
nvm install 24

# 5. 切换到 24 版本
nvm use 24

# 6. 设置默认版本
nvm alias default 24

# 7. 验证 Node.js 版本
node -v # 应显示 v24.x.x >=22 满足 OpenClaw 要求

# 8. 验证 npm 版本
npm -v

# 9. 配置 npm 镜像
npm config set registry https://registry.npmmirror.com

image-20260309153446905

2.2 通过npm安装OpenClaw指定版本

选择使用npm安装的原因:适用于全平台的安装方式+可以指定安装版本(版本管理更清晰+便于后续升级维护)

1
2
# 安装OpenClaw最新版本或安装指定版本如 npm install -g openclaw@2026.3.2
npm install -g openclaw@latest

image-20260309155154045

2.3 运行OpenClaw安装向导

1
2
3
4
5
# 完整安装向导+安装系统服务
openclaw onboard --install-daemon

# 或仅运行配置向导
openclaw onboard

image-20260309155231001

image-20260309155352839

2.3.1 配置模型

注:根据实际情况配置,这里使用的是腾讯CodingPlan

image-20260309155505547

image-20260309162240189

2.3.2 配置通道&安装技能 (先跳过)

其他也都先略过。

2.3.3 检查安装

等待安装完成,安装完成后可运行以下命令来检查或排错:

1
2
3
4
5
6
7
openclaw status
openclaw status --all
openclaw gateway probe
openclaw gateway status
openclaw doctor
openclaw channels status --probe
openclaw logs --follow

image-20260309171455299

3.访问网页控制台

3.1 配置通过密钥登录云服务器

由于使用的云服务器ubuntu系统是不带图形界面的、且ubuntu系统默认禁止root用户远程登录,因此配置通过密钥登录云服务器 (相对更安全便捷)

1
2
3
4
5
6
7
8
9
10
11
# 1.生成密钥 (不指定路径,使用默认设置)
ssh-keygen -t ed25519
# 提示时直接按 Enter (使用默认路径)
# 提示输入密码时直接按 Enter 两次 (不设置密码)

# 2.先用普通用户(ubuntu系统默认使用ubuntu用户) 登录服务器添加公钥
$pubKey = Get-Content C:\Users\用户名\.ssh\id_ed25519.pub
ssh ubuntu@<云服务器IP> "sudo mkdir -p /root/.ssh && echo '$pubKey' | sudo tee /root/.ssh/authorized_keys && sudo chmod 700 /root/.ssh && sudo chmod 600 /root/.ssh/authorized_keys"

# 3.测试通过 root 登录
ssh root@<云服务器IP>

3.2 通过隧道访问控制台

可以成功通过root用户登录云服务器之后,运行以下命令 (运行后不要退出或关闭终端窗口):

1
ssh -N -L 18789:127.0.0.1:18789 root@<云服务器IP>

接下来就可以打开浏览器访问控制台了 (网址:http://127.0.0.1:18789/#token=xxx ):

具体的token值在安装完成后会显示、也可以通过openclaw dashboard命令查看

image-20260310113042343

可直接通过Chat/聊天页面进行对话 (默认已经有了1个Agent/代理),比如问“怎么通过网页控制台配置飞书通道”:

image-20260310142107980

image-20260310142224013

通过网页控制台可以查看OpenClaw的相关信息,后续也可以直接通过控制台来配置管理通道、技能等。

4.版本升级

目前OpenClaw迭代很快,npm方式部署的升级方法 (或通过网页控制台进行升级):

1
2
3
4
5
6
7
8
# 1.查看当前安装的版本
openclaw --version

# 2.查看 npm 上最新版本
npm view openclaw version

# 3.升级
npm i -g openclaw@latest

image-20260310164605694

升级后步骤:

1
2
3
4
5
6
7
8
# 1.运行 doctor 修复/迁移配置 (按需)
openclaw doctor

# 2.重启 Gateway
openclaw gateway restart

# 3.检查健康状态
openclaw health

其他相关命令:

1
2
3
4
5
6
7
8
9
10
11
# 切换到 beta 通道
openclaw update --channel beta

# 切换到 dev 通道
openclaw update --channel dev

# 切换回稳定版
openclaw update --channel stable

# 回滚到指定版本
npm i -g openclaw@<版本号>

相关链接