在linux服务器上部署openclaw-zh汉化版
有以下前置条件:
- linux上已有docker,所以我将按照docker的方式部署openclaw
- 飞书上已创建个人应用,链接:飞书对接指南
- 使用美团的longcat作为模型,链接: OpenClaw 配置
部署openclaw的完整必要步骤
OpenClaw(原 Clawdbot/Moltbot)是一个强大的开源个人 AI Agent 平台,支持接入 Claude/ChatGPT 等大模型、多平台聊天机器人(如 Telegram/WhatsApp),汉化版(openclaw-zh)界面全中文,更适合国内用户。
我在服务器(华为云 ECS,amd64 架构)上部署时,踩了无数坑:
- 镜像架构不匹配导致 exec format error
- 配置未生效,gateway 闪退(Missing config / no token)
- 远程访问 disconnected (1008) 安全上下文错误
- 端口冲突、防火墙、安全组、bind 配置遗漏
- volume 挂载路径写错导致数据丢失或不生效
最终成功方案如下(已亲测稳定运行)。全文命令均基于 Docker + bind mount 宿主机目录方式(/root/lee/openclaw/.openclaw),避免 named volume 迁移麻烦。
完整部署脚本(复制粘贴即可)
1 |
|
常见踩坑 & 注意事项(博客核心内容)
镜像架构必须匹配
服务器 amd64,但 nightly/latest 版有时默认拉 arm64 →exec format error。
解决:始终加--platform linux/amd64。volume 挂载路径写错最致命
错误示例:-v ~/.openclaw:...或多挂载 → 配置不生效、数据丢失。
正确:用绝对路径/root/xxx/...:/root/.openclaw,且只挂载一个。gateway.mode 未设 local → 闪退
日志:Missing config…
必须先 setup,再 set local。token 配置缺失 → Gateway auth error
默认 token 模式但无值 → 启动失败。
用doctor --fix自动生成,或手动config set gateway.auth.token "xxx"。远程访问 disconnected (1008)
浏览器安全上下文要求 HTTPS 或 localhost。
解决:gateway.controlUi.allowInsecureAuth true(token-only,适合内网/测试)- 公网强烈推荐 Tailscale Serve / Nginx + HTTPS 反代(更安全)
- 访问时必须带 token:
http://IP:13004/?token=你的token
端口/防火墙/安全组
- 服务器本地:
ss -tuln | grep 13004看到监听 - 云控制台安全组 + firewalld/ufw 必须放行 13004/tcp
- 否则 curl/telnet 超时,浏览器 Connection refused。
- 服务器本地:
其他高频坑
- 首次 dashboard 需 pairing:日志显示 request id,用
openclaw pairing approve <id>批准(或用带 token 的 URL 自动)。 - 配置不生效?删目录重 init(备份先!)。
- 弱服务器:pull/setup 阶段 CPU/IO 高,耐心等,别 Ctrl+C 中断。
- 升级镜像:先
docker pull新版,再重启容器(数据在宿主机目录,不丢)。
- 首次 dashboard 需 pairing:日志显示 request id,用
安全提醒
- 定期备份
/root/lee/openclaw/.openclaw目录。
使用 LiteLLM 代理
总结:LiteLLM 把你的多个 API Key 伪装成一个统一的 OpenAI 接口,OpenClaw 只认这一个代理,就能自动轮询多个 Key,避免限流,配置简单、运行稳定。
LiteLLM 不需要放在 Docker 里,推荐直接在服务器宿主机(即 Linux 系统本身)上安装和运行。必须升级 Python 到 3.10 或 3.11(推荐 3.11,最稳定)。
安装好LiteLLM(1.81.11)后,建议在venv上运行。
1 | mkdir -p ~/litellm && cd ~/litellm |
- 创建 LiteLLM 配置文件
1 | vim litellm_config.yaml |
说明:OpenClaw 发送的 store 参数不被 LongCat API 支持,导致 UnsupportedParamsError,所以drop_params一定要填,用于过滤参数
- 运行 LiteLLM 代理(推荐用 screen,稳)
1 | screen -S litellm # 新开一个 screen 会话 |
相关命令
1 | 按 Ctrl+A 然后 D 脱离 screen(代理继续后台运行)。 |
