一、写在前面
2026 年初,一个叫 OpenClaw(🦞 龙虾)的开源项目以惊人速度席卷 GitHub——2026 年 3 月 3 日正式超越 React,成为 GitHub 史上 Stars 最多的软件项目,彼时仅用了约 60 天,而 React 实现这一里程碑用了超过十年。截至 2026 年 3 月底,OpenClaw 已累计突破 34 万 Stars,且增速未有停止迹象。与此同时,其网站月访问量已达 2700 万次,月活跃用户超过 200 万。
OpenClaw 的核心理念极其简单:把强大的 AI 大模型接入你已经在用的聊天软件——企业微信、Telegram、Discord、飞书……然后让这个 Agent 24 小时在你的服务器上跑,帮你执行任务、管理文件、自动化工作流。腾讯云、阿里云均已推出一键部署服务,包括推出自家的 OpenClaw 服务。
本文是一篇之前安装 OpenClaw 的草稿记录,目前有需要古法安装 OpenClaw 的可以参考。
文章结构如下:
OpenClaw 是什么 环境准备 一键安装 OpenClaw 交互式引导配置详解 接入企业微信智能机器人 常见问题处理
二、OpenClaw 是什么
OpenClaw 是一个本地优先的 AI Agent 网关,开源免费(MIT 协议),由 PSPDFKit 创始人 Peter Steinberger 于 2025 年 11 月作为周末项目发布,最初名为 Clawdbot,经历 Moltbot 短暂过渡后,于 2026 年 1 月 30 日正式定名 OpenClaw。它的工作方式是:
你的手机/电脑(企业微信 / Discord / Telegram)↕OpenClaw Gateway(跑在你的服务器)↕大模型 API(Claude / GPT / MiniMax / DeepSeek / 本地 Ollama)
你通过聊天消息下指令,Gateway 负责调度模型推理、工具调用、会话记忆,再把结果回传给你。支持超过 20 个主流 IM 平台。技能生态方面,ClawHub 社区技能库从 2026 年 2 月初的 5,700 个迅速增长至 3 月底的 13,729 个,其中超过 65% 封装了 MCP 服务器,生态扩展速度极快。
对国内用户来说,OpenClaw 原生支持 MiniMax、DeepSeek等国产模型,企业微信由腾讯官方适配,提供稳定的长连接机器人接入,无需公网回调地址,是国内私有化部署的最佳选择之一。
三、环境准备
阿里云ECS:CPU 2核、内存 2G 、磁盘 40G;
部署环境:Ubuntu 24.04 64 位;
Node.js:推荐 Node.js 24,最低支持 Node.js 22.16+。如果缺失,安装脚本会安装 Node 24
Node.js 安装:
# 安装 nvm:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash# 替代重启终端:\. "$HOME/.nvm/nvm.sh"# 下载并安装 Node.js:nvm install 24# 验证 Node.js 版本:node -v # 打印 "v24.14.1".# Verify npm version:npm -v # 打印 "11.11.0".
四、安装 OpenClaw
准备好 Node 环境之后,直接运行官方安装脚本:
curl -fsSL https://openclaw.ai/install.sh | bash安装器会自动检测操作系统、拉取最新版本并配置 npm 包。成功后你会看到类似输出:
root@jpz:~# curl -fsSL https://openclaw.ai/install.sh | bash🦞 OpenClaw InstallerI'm the reason your shell history looks like a hacker-movie montage.✓ Detected: linuxInstall planOS: linuxInstall method: npmRequested version: latest[1/3] Preparing environment✓ Node.js v22.22.1 found· Active Node.js: v22.22.1 (/root/.nvm/versions/node/v22.22.1/bin/node)· Active npm: 10.9.4 (/root/.nvm/versions/node/v22.22.1/bin/npm)[2/3] Installing OpenClaw✓ Git already installed· Installing OpenClaw v2026.3.8✓ OpenClaw npm package installed✓ OpenClaw installed[3/3] Finalizing setup🦞 OpenClaw installed successfully (OpenClaw 2026.3.8 (3caab92))!
五、交互式引导配置详解
安装完成后,脚本会自动进入 Onboarding 向导,逐步引导你完成初始配置。以下对每个配置项逐一说明。
(1). 安全警告确认
第一个界面是安全声明,确认理解后选择 Yes 继续。
🦞 OpenClaw 2026.3.8 (3caab92) — Say "stop" and I'll stop—say "ship" and we'll both learn a lesson.▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░████░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░████░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀🦞 OPENCLAW 🦞┌ OpenClaw onboarding│◇ Security ─────────────────────────────────────────────────────────────────────────────────╮│ ││ Security warning — please read. ││ ││ OpenClaw is a hobby project and still in beta. Expect sharp edges. ││ By default, OpenClaw is a personal agent: one trusted operator boundary. │... ...│◇ I understand this is personal-by-default and shared/multi-user use requires lock-down. Continue?│ Yes
(2). 安装模式选择
Onboarding Mode:选择 Manual手动配置,可精细控制每个选项;QuickStart模式会跳过大部分配置使用默认值,适合快速体验。
... ...◇ Onboarding mode│ Manual│... ...
安装模式:选择 Local gateway (this machine),在本机运行 Gateway。
... ...◇ What do you want to set up?│ Local gateway (this machine)... ...
(3). 工作目录与模型配置
Gateway 工作目录: 默认为 ~/.openclaw/workspace,保持默认即可
... ...◇ Workspace directory│ /root/.openclaw/workspace... ...
模型/认证提供商:初次部署可以先跳过,后续在配置文件 ~/.openclaw/openclaw.json中手动添加 API Key。
... ...◇ Model/auth provider│ Skip for now... ...
如果现在就要配置,选择对应的提供商后,再选择默认模型。本文示例选择 MiniMax 节点,也可以选择 Claude、OpenAI 等其他提供商。
... ...◇ Filter models by provider│ minimax│◇ Default model│ minimax/MiniMax-M2.5-highspeed... ...
⚠️ 注意:选择了模型提供商但未配置认证信息时,Agent 启动后会提示鉴权失败。需在配置文件中补充对应的
json"providers": {"minimax": { "apiKey": "你的API Key" }}
(4). Gateway 网络配置
Gateway 端口 18789(默认) OpenClaw 监听的网络端口,外部通过此端口与 Gateway 通信。浏览器访问 http://your-server-ip:18789即可打开 Web UI,管理 Agent、查看会话、配置渠道;同时也是所有 API 调用和频道消息的统一入口,默认 18789,如有端口冲突可自行修改。
... ...◇ Gateway port│ 18789... ...
绑定方式 LAN (0.0.0.0) 决定哪些网络来源可以访问 Gateway。
... ...◇ Gateway bind│ LAN (0.0.0.0)... ...
LAN (0.0.0.0):监听所有网卡,局域网和公网均可访问,推荐服务器部署使用;loopback (127.0.0.1):仅允许本机访问,适合本地开发调试;若同时启用 Tailscale,系统会自动将此项改为 loopback;(5). 认证方式
认证方式 Token 客户端请求时需在 Header 中携带 Token 才能通过鉴权,防止 Gateway 被未授权访问
... ...◇ Gateway auth│ Token... ...
SSH 隧道 本地部署不考虑安全则选择 off,否则⽤ Tailscale 做 HTTPS 代理。
◇ Tailscale exposure│ Off
Gateway Token 生成:
Token 是访问 Gateway 的唯一凭证,留空回车自动生成随机 Token,请妥善保存,后续 Web UI 登录和 API 调用均需用到。
◇ How do you want to provide the gateway token?│ Generate/store plaintext token│◇ Gateway token (blank to generate)│ *** ***
(6). Channels 配置
向导会列出所有支持的 Channels 及其当前状态,选择需要配置的 Channels,可以跳过。 跳过后需要配置渠道时,执行:
◇ Configure chat channels now?│ No
openclaw channels add(7). 网络搜索
为 Agent 开启联网搜索能力,初次部署可跳过。
◇ Search provider│ Skip for now
(8). Skills 配置
Skills 是 Agent 可调用的工具能力,如文件操作、代码执行、日历读写等。向导会显示当前系统满足运行条件的 Skills 数量,可以现在配置,也可以后续通过 openclaw skills 命令管理。
◇ Configure skills now?│ No
(9). DM 访问策略
控制哪些用户可以直接私聊 Agent。默认为 pairing(配对模式),未知用户发消息会收到配对码,需在服务端审批后才能正常对话,安全性较高。
◇ Configure DM access policies now? (default: pairing)│ No
pairing:默认,未知用户需配对审批`;open:所有用户可直接私聊,适合开放场景`;allowlist:仅白名单用户可私聊,最严格`;
(10). Hooks 配置(推荐开启)
Hooks 在特定事件触发时自动执行预设动作,向导提供两个开箱即用的 Hook:
◇ Enable hooks?│ 🚀 boot-md, 💾 session-memory
boot-md:Gateway 启动时自动加载 Markdown 格式的引导说明,适合自定义 Agent 的启动行为session-memory:执行/new或/reset时自动将当前会话上下文保存到记忆,避免重要信息丢失
后续通过以下命令管理:
openclaw hooks listopenclaw hooks enable <name>openclaw hooks disable <name>
(11). Systemd 服务安装
向导会自动将 Gateway 注册为 systemd 用户级服务,并开启 linger(即使退出登录,服务也持续运行)。
◇ Install Gateway service (recommended)│ Yes
systemctl --user status openclaw-gatewaysystemctl --user status openclaw-gateway.service
(12). Gateway 启动⽅式
使⽤默认⽅式即可。
◇ Gateway service runtime│ Node (recommended)
六、配置⽂件
配置⽂件位置: ~/.openclaw/openclaw.json
常用配置说明:
{"meta": {// meta 块:系统元数据(自动维护)// 作用:记录配置文件的版本和最后修改时间// 帮助 OpenClaw 判断配置兼容性、是否需要迁移等// 通常不需要手动修改"lastTouchedVersion": "2026.3.13","lastTouchedAt": "2026-03-20T02:50:52.873Z"},"env": {// env 块:自定义环境变量// 作用:定义可在配置文件其他地方引用的变量(使用 $变量名 语法)// 主要用于存放敏感信息(如 API Key),避免明文重复出现// 推荐做法:把真实 Key 放到系统环境变量中,这里只写引用"MINIMAX_API_KEY": "你的完整真实key"},"wizard": {// wizard 块:配置向导运行记录(系统自动维护)// 作用:记录最后一次运行 openclaw onboard / doctor / configure 等向导命令的信息// 用于判断是否需要重新运行初始化向导、显示配置状态等// 通常不需要手动修改"lastRunAt": "2026-03-20T02:50:52.818Z","lastRunVersion": "2026.3.13","lastRunCommand": "doctor","lastRunMode": "local"},"auth": {// auth 块:认证配置(认证 profiles)// 作用:为不同的模型提供商定义认证方式和认证 profile// 支持为同一个 provider 创建多个认证配置(default / backup 等)// 后面 models 块会引用这里的 profile 来进行 API 认证"profiles": {"minimax:default": { // MiniMax 默认认证配置"provider": "minimax","mode": "api_key"}}},"models": {// models 块:模型提供商和模型定义(核心配置)// 作用:自定义或扩展 OpenClaw 支持的 AI 模型"mode": "merge", // 合并模式:推荐使用,不会覆盖系统内置模型"providers": {"minimax": { // 自定义 MiniMax 提供商配置"baseUrl": "https://api.minimaxi.com/anthropic", // MiniMax 的 Anthropic 兼容接口地址"apiKey": "$MINIMAX_API_KEY", // 引用上面 env 中定义的密钥"api": "anthropic-messages", // 使用 Anthropic Messages API 协议(推荐)"authHeader": false, // 是否需要额外 Authorization Header(此接口通常为 false)"models": [ // 定义具体模型列表{"id": "MiniMax-M2.7-highspeed", // 模型唯一标识,后续调用时常用 minimax/MiniMax-M2.7-highspeed"name": "MiniMax M2.7 Highspeed", // 显示名称"api": "anthropic-messages", // 该模型使用的 API 类型"reasoning": false, // 关闭原生推理模式,避免兼容性问题"input": ["text"], // 支持输入类型(目前仅文本)"cost": { // 计费价格(单位通常为百万 token)"input": 15, // 输入价格"output": 60, // 输出价格"cacheRead": 2, // 缓存读取价格"cacheWrite": 10 // 缓存写入价格},"contextWindow": 200000,// 上下文窗口:20万 token(很大)"maxTokens": 8192 // 单次最大输出 token 数}]}}}}
七、接入企业微信智能机器人
接入企业微信有两个插件:
(1)企业微信官方:
https://open.work.weixin.qq.com/help2/pc/cat?doc_id=21657
(2)第三方插件:
https://github.com/BytePioneer-AI/openclaw-china
整个流程分两部分:在企业微信后台创建机器人,再在服务器侧安装插件并完成绑定。这部分目前微信的文档比较详细,这里不再具体说明。
八、常用命令
(1)核心服务管理
openclaw onboard | openclaw onboard --install-daemon | |
openclaw gateway | openclaw gateway startopenclaw gateway stop(停止)openclaw gateway restart(重启)openclaw gateway run(前台运行,调试用) | |
openclaw status | openclaw status --all | |
openclaw health | ||
openclaw doctor | openclaw doctor --fix | |
openclaw dashboard | ||
openclaw tui | ||
openclaw update | ||
openclaw logs | openclaw logs --follow |
(2)配置管理
openclaw config | configure) |
openclaw config get <key> | |
openclaw config set <key> <value> | |
openclaw config validate |
(3)模型管理
openclaw models list | |
openclaw models status |
(4)通道/会话管理(Channels & Sessions)
openclaw channels list | |
openclaw channels status | |
openclaw sessions list | |
openclaw sessions send <session_key> "消息" |
(5)Skills / Plugins 管理
openclaw skills list | |
openclaw skills install <name> | |
openclaw plugins list | |
openclaw plugins install |
更多详细命令可以运行 openclaw --help 或 openclaw <命令> --help 查看。
九、常见问题处理
问题 1:Gateway 崩溃 / 内存溢出(OOM)
Gateway 崩溃 / 内存溢出(OOM)
修复:
# 查看内存使用ps aux --sort=-%mem | grep openclaw# 方案 A:降级到内存占用较低的版本npm install -g openclaw@2026.3.11# 方案 B:限制 Node.js 堆内存(在 gateway 启动命令中加 --max-old-space-size)openclaw config set gateway.nodeOptions "--max-old-space-size=512"openclaw gateway restart# 方案 C:Docker 限制内存docker run -m 2g openclaw/openclaw:latest
问题 2:GateWay 拒绝 HTTP 访问
如果通过 HTTP 访问 Gateway WebUI(非 HTTPS),部分浏览器会限制某些 API 特性。
Edge 浏览器:地址栏输入 edge://flags/,搜索并启用 Insecure origins treated as secure,在输入框填入 Gateway 地址(如 http://your-server-ip:18789),重启浏览器即可。
Chrome 使用 chrome://flags/ 同理。
或者参考:https://docs.openclaw.ai/gateway/security
问题 3:systemd 服务找不到
sudo systemctl restart openclaw# Failed to restart openclaw.service: Unit openclaw.service not found.
原因:OpenClaw 安装的是 systemd 用户级服务,不是系统级服务,不能用 sudo systemctl 管理。
解决方法:
# 正确的启动/重启方式(不带 sudo)systemctl --user restart openclaw-gateway# 或者通过 openclaw 命令重新安装守护进程openclaw onboard --install-daemon
问题 4:配置了 Tailscale 后 bind 冲突
如果在引导中选择了 Tailscale Serve 模式,系统会自动将 gateway.bind 改为 loopback,导致局域网/公网无法直接访问。
解决方法——切换回公网 IP 访问模式:
# 第一步:关掉 Tailscale 冲突模式openclaw config set gateway.tailscale.mode off# 第二步:切换绑定模式为局域网/公网openclaw config set gateway.bind lan# 第三步:重启服务应用更改systemctl --user restart openclaw-gateway
问题 5:查看 Gateway 运行状态与日志
# 查看整体状态openclaw status# 深度状态检查openclaw status --deep# 实时跟踪日志openclaw logs --follow
问题 6:添加或切换模型
配置文件位于 ~/.openclaw/openclaw.json,models 部分示例如下:
"models": {"minimax-cn/MiniMax-M2.5-highspeed": {},"minimax/MiniMax-M2.5-highspeed": {"alias": "Minimax"}}
修改配置后重启 Gateway 生效。
问题 7:诊断工具箱
# 运行官方诊断工具(覆盖配置、端口、服务状态)openclaw doctor# 检查 Gateway 健康状态curl -s http://127.0.0.1:18789/health | python3 -m json.tool# 查看端口监听lsof -i :18789# 检查守护进程# macOSlaunchctl list | grep openclaw# Linuxsystemctl --user status openclaw-gateway# 查看实时 debug 日志openclaw logs --follow --level debug# 检查 npm 包安装状态npm list -g --depth=0 | grep openclaw# 检查 Node.js 版本(要求 ≥22)node --version# 检查配置文件格式合法性python3 -m json.tool ~/.openclaw/agents/main/agent/auth-profiles.json
十、小结
如果你在部署过程中遇到问题,可以优先查看官方文档。
夜雨聆风