部署 Openclaw
服务器配置与部署

部署 Openclaw

JACIN··9 分钟阅读

使用官方部署方式, 需要注意网络问题,本次部署机为 德国 vps。

一键安装

text
curl -fsSL https://openclaw.ai/install.sh | bash

选择 codex 认证:

image|690x210

它会自动做的事

  • 检测到你已经安装了 OpenClaw
  • 下载最新版本
  • 原地升级(in-place upgrade)
  • 自动运行 openclaw doctor 检查
  • 重启服务
text
# 检查当前版本和是否有更新
openclaw update status

# 一键安全更新(推荐)
openclaw update

# 更新后不自动重启服务(可选)
openclaw update --no-restart

卸载#

text
# 1. 用内置卸载器彻底删除(服务 + 数据 + 配置)
openclaw uninstall --all --yes --non-interactive

# 2. 强制删除所有残留文件夹(最重要!Grok 的缓存全在这里)
rm -rf ~/.openclaw
rm -rf ~/.clawdbot
rm -rf ~/clawdbot

# 3. 删除全局 CLI(防止旧命令残留)
npm uninstall -g openclaw || pnpm remove -g openclaw || bun remove -g openclaw

# 4. 杀掉所有可能残留进程
pkill -9 -f openclaw || true
pkill -9 -f clawdbot || true

配置tg 机器人#

去 @BotFather 创建机器人 输入 /newbot 就可以,后面配置信息就可以了。

跟机器人对话后,xxxx 就是Pairing code:
这样可以只让这个用户进行操作

text
openclaw pairing approve telegram xxxx

第1步:关闭 Privacy Mode(最关键!)

  1. 打开 Telegram,搜索 @BotFather
  2. 发送 /setprivacy
  3. 选择你的机器人(@claxxxxx)
  4. 选择 Disable(关闭隐私模式)
  5. BotFather 会回复 “Privacy mode is disabled for ...”

第2步:把机器人设为群组管理员

  1. 进入群组 “ai投资论”
  2. 点击群组名称 → “管理群组” 或 “添加管理员”
  3. 找到你的机器人 @claw_987_ai_bot,点击添加为管理员
  4. 务必勾上以下权限
  • 发送消息
  • 读取所有群组消息(Read all group messages)← 这个最重要!
  • 发送媒体消息(可选)

文档: https://docs.openclaw.ai/zh-CN/channels/telegram#%E7%BE%A4%E7%BB%84%E6%BF%80%E6%B4%BB%E6%A8%A1%E5%BC%8F

错误解决#

跨域解决#

origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)

vim ~/.openclaw/openclaw.json

text
"gateway": {
  "bind": "0.0.0.0",
  "port": 18789,
  "controlUi": {
    "allowedOrigins": [
      "https://openclaw.jacin.me",
      "http://localhost:18789",
      "http://127.0.0.1:18789"
    ],
    "allowInsecureAuth": true
  }
}

设备允许#

pairing required This device needs pairing approval from the gateway host. openclaw devices list openclaw devices approve On mobile? Copy the full URL (including #token=...) from openclaw dashboard --no-open on your desktop. Docs: Device pairing

这是 OpenClaw 故意设置的安全机制(2026 年版本加强的),不是 bug。

意思是:你从浏览器第一次访问网页仪表盘时,OpenClaw 把这个浏览器当成“新设备”,需要你在服务器上手动批准一次,才能正常使用 Logs、Channels、Chat 等功能。

之前 origin not allowed 解决了之后,这个 pairing 就会跳出来。

text
# 1. 查看需要批准的设备列表
openclaw devices list

Pending requests:
  requestId:   xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  device:      openclaw-control-ui
  IP:          你的IP
  time:        just now

# 2. 批准(把 xxxxxxxx 换成你看到的实际 requestId)
openclaw devices approve xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

或者直接批准所有 pending 的(最快):
Bash
openclaw devices approve --all

评论

还没有评论,来发第一个吧