OpenClaw 部署与使用指南
OpenClaw 是一个开源的个人 AI 助手项目,2026 年 1 月在 GitHub 上火了起来。和其他只能聊天的 AI 不同,OpenClaw 可以直接操作你的系统------读写文件、执行命令、跑代码、操作浏览器、处理邮件等等。
简单说,它不是和你对话的工具,而是帮你干活的工具。
关于项目名称
你可能看到过三个名字:Clawdbot、Moltbot、OpenClaw。这是一个项目:
- 最早叫 Clawdbot
- 1 月底因为商标问题改名为 Moltbot
- 最后定名为 OpenClaw
功能完全一样,命令也兼容。
本地安装
一键安装
最简单的方式,直接运行安装脚本:
macOS/Linux:
bash
curl -fsSL https://openclaw.ai/install.sh | bash
Windows PowerShell:
powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
Windows CMD:
cmd
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
手动安装
如果已经装了 Node.js ≥22:
bash
npm i -g openclaw
# 或
pnpm add -g openclaw
然后运行初始化:
bash
openclaw onboard
从源码安装
bash
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm ui:build
pnpm build
pnpm openclaw onboard --install-daemon
pnpm gateway:watch
初始化配置
安装完成后会进入配置向导,几个关键选项说明一下:
风险确认:OpenClaw 需要系统权限来完成任务,选 Yes 继续。
安装模式:新手选 QuickStart 即可。
AI 模型:
国内用户可以用 Qwen、MiniMax、智谱。有海外账号的推荐 Claude 或 GPT-4。暂时不确定可以先跳过,后面通过配置文件改。
聊天通道:
海外用户选 WhatsApp/Telegram/Discord,国内用户可以跳过,后面配置飞书。
端口:默认 18789,不用改。
配置完成后浏览器会自动打开 http://127.0.0.1:18789/chat
云服务器部署
阿里云和腾讯云都有现成的镜像,可以直接用。
阿里云
https://www.aliyun.com/activity/ecs/clawdbot
腾讯云
https://cloud.tencent.com/developer/article/2624973
步骤:
-
用 OpenClaw 镜像重装系统(注意不是 Moltbot)
-
登录服务器终端,运行
openclaw onboard
后续配置和本地安装一样。如果要用国内模型,建议先跳过模型配置,后面手动改配置文件。
公网访问配置
云服务器部署后如果需要从外网访问,需要额外配置。
WebSocket 配置
接入 Telegram/WhatsApp 等需要:
bash
openclaw configure
把 Gateway 地址改成公网 IP:
认证方式选 Token。
Web UI 远程访问
编辑 ~/.openclaw/openclaw.json,把 mode 改成 remote,bind 改成 lan,然后重启服务。
bash
openclaw gateway stop
openclaw gateway start
查看 token:
bash
cat ~/.openclaw/openclaw.json
访问 URL 加上 &token=xxx
设备授权
如果出现 pairing required 错误:
bash
openclaw devices list
复制 Pending 里的 Request ID 授权:
bash
openclaw devices approve b8eb70dd...
国内模型配置
Moonshot (Kimi)
- 创建 API Key:https://platform.moonshot.cn/console/api-keys
- 查看可用模型:https://platform.moonshot.cn/playground
Kimi Code
-
购买编程模型:https://www.kimi.com/code
-
创建 API Key:https://www.kimi.com/code/console?from=kfc_overview_topbar
修改配置文件
编辑 ~/.openclaw/openclaw.json,把下面的内容加进去(替换 API Key):
json
{
"agents": {
"defaults": {
"model": {
"primary": "moonshot/kimi-k2.5"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
},
"workspace": "/root/.openclaw/workspace"
}
},
"models": {
"mode": "merge",
"providers": {
"moonshot": {
"baseUrl": "https://api.moonshot.cn/v1",
"apiKey": "${MOONSHOT_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "kimi-k2.5",
"name": "Kimi K2.5"
}
]
},
"kimi-code": {
"baseUrl": "https://api.kimi.com/coding/v1",
"apiKey": "${KIMICODE_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "kimi-for-coding",
"name": "Kimi For Coding"
}
]
}
}
}
}
重启服务生效:
bash
openclaw gateway restart
飞书集成
1. 创建飞书应用
打开 https://open.feishu.cn/app,创建应用,添加机器人能力。
2. 配置权限
开通消息和群组相关权限。
3. 配置事件
使用长连接,添加消息接收事件。
4. 连接 OpenClaw
bash
openclaw configure
选择 Channels,填入飞书的 App ID 和 App Secret。
常用命令
基础
bash
openclaw status # 运行状态
openclaw health # 健康检查
openclaw doctor # 诊断问题
openclaw doctor --deep # 深度检查
openclaw configure # 修改配置
Gateway
bash
openclaw gateway start
openclaw gateway stop
openclaw gateway restart
openclaw gateway status
通道
bash
openclaw channels list
openclaw channels login # WhatsApp 扫码
openclaw channels add # 添加 Telegram/Discord
openclaw channels status --probe
模型
bash
openclaw models list
openclaw models status
openclaw models auth setup-token
配置
bash
openclaw config get <path>
openclaw config set <path> <value>
openclaw config unset <path>
日志
bash
openclaw logs
openclaw logs --follow
记忆和技能
bash
openclaw memory search "关键词"
openclaw memory index
openclaw skills list
clawhub install <skill>
文件路径
| 路径 | 用途 |
|---|---|
~/.openclaw/openclaw.json |
主配置文件 |
~/.openclaw/workspace/ |
工作区 |
~/.openclaw/credentials/ |
API 密钥 |
~/.openclaw/memory/ |
长期记忆存储 |
~/.openclaw/skills/ |
技能目录 |
/tmp/openclaw/*.log |
日志文件 |
工作区文件:
AGENTS.md- 给 AI 的指令USER.md- 用户偏好MEMORY.md- 长期记忆HEARTBEAT.md- 定期检查清单SOUL.md- 人格设定BOOT.md- 启动配置
聊天命令
在聊天界面可以用:
/status 查看状态
/context list 查看上下文
/model <模型> 切换模型
/compact 精简窗口
/new 新对话
/stop 停止任务
/tts on/off 语音开关
/think 切换推理模式
常见问题
| 问题 | 解决 |
|---|---|
| 不回消息 | openclaw status |
| 私信没反应 | openclaw devices list 批准设备 |
| 群里不响应 | 检查提及模式 |
| 认证过期 | openclaw models auth setup-token |
| 服务异常 | openclaw doctor --deep |
| 记忆问题 | openclaw memory index |
参考链接
- GitHub: https://github.com/openclaw/openclaw
- 官方文档: https://openclaw.ai/docs
- 技能合集: https://github.com/VoltAgent/awesome-openclaw-skills