OpenClaw 作为 2026 年最热门的开源 AI 助手框架,网上有很多很方便甚至一键式的安装方式,本文记录了使用腾讯云服务器手动安装OpenClaw的过程。

一、环境准备

1.1 系统信息

  • 操作系统: OpenCloudOS 9.4
  • 安全组: 需开放 18789 端口(Gateway 默认端口)

1.2 安装 Node.js

OpenCloudOS 使用 yum 包管理器,直接安装 Node.js:

sudo yum install -y nodejs

注意: 如果系统 Node.js 版本低于 22,建议通过 nvm 安装最新版:

# 安装 nvm(Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# 或者使用 fnm(更快)
curl -fsSL https://fnm.vercel.app/install | bash

# 安装 Node.js 22
nvm install 22
node -v  # 验证版本

二、安装 OpenClaw

2.1 全局安装 CLI

sudo npm install -g openclaw@latest

验证安装:

openclaw --version
# 输出: OpenClaw 2026.3.8

2.2 运行初始化向导

# 初始化配置并安装系统服务
openclaw onboard --install-daemon

向导会引导完成:

  1. Gateway 配置: 设置端口(默认 18789)
  2. Workspace: 工作目录设置
  3. Channel: 聊天渠道(WhatsApp/Telegram/飞书等)
  4. Skill: 从 ClawHub 安装技能包

三、踩坑与解决方案

1: Gateway start blocked(运行模式未设置)

现象: 执行 openclaw gateway 后提示 Gateway start blocked,服务无法启动。

在这里插入图片描述

原因: OpenClaw 出于安全考虑,要求必须显式设置运行模式(开发测试/生产部署),系统不知道当前环境用途,因此阻止启动 。

解决: 设置本地运行模式

# 设置运行模式为 local
openclaw config set gateway.mode local

# 启动网关
openclaw gateway

配置成功后,Gateway 将正常启动并监听端口。

2: Control UI 设备身份验证失败

现象: 浏览器访问 http://<公网IP>:18789 提示:

control ui requires device identity (use HTTPS or localhost secure context)

原因: OpenClaw 的 Control UI 默认要求安全的设备身份验证,在 HTTP + 公网 IP 环境下会被阻止 。

解决: 修改配置文件,仅在受信任的内网环境 临时禁用设备认证:

# 编辑配置文件
vim ~/.openclaw/openclaw.json

gateway.controlUi 下添加:

{
  "gateway": {
    "controlUi": {
      "dangerouslyDisableDeviceAuth": true,
      "allowInsecureAuth": true
    },
    "bind": "lan",
    "mode": "local"
  }
}

注意: dangerouslyDisableDeviceAuth 会移除设备身份验证,仅建议在受信任的局域网或测试环境使用,生产环境请务必使用 HTTPS + Token 认证 。

重启 Gateway 生效:

openclaw gateway restart

附:

绑定模式详解

模式 说明 适用场景
loopback 仅 127.0.0.1 本地开发
lan 监听所有网卡 云服务器/局域网
tailnet Tailscale VPN 网络 零信任安全访问
auto 自动检测 智能选择
custom 自定义 host 特殊网络环境

常用命令速查

命令 说明
openclaw --version 查看版本
openclaw onboard 运行配置向导
openclaw gateway 启动网关(前台)
openclaw gateway start 启动服务(后台)
openclaw gateway stop 停止服务
openclaw gateway status 查看网关状态
openclaw gateway restart 重启网关
openclaw dashboard 打开 Web 控制台
openclaw doctor 诊断检查
openclaw logs --follow 实时查看日志
openclaw config get 查看当前配置
openclaw config set <key> <value> 修改配置
openclaw channels login 登录聊天渠道
openclaw devices list 查看设备列表

openclaw.json

配置文件(~/.openclaw/openclaw.json):

{
  "meta": {
    "lastTouchedVersion": "2026.3.12",
    "lastTouchedAt": "2026-03-14T11:03:16.024Z"
  },
  "wizard": {
    "lastRunAt": "2026-03-14T11:03:15.984Z",
    "lastRunVersion": "2026.3.12",
    "lastRunCommand": "configure",
    "lastRunMode": "local"
  },
  "auth": {
    "profiles": {
      "zai:default": {
        "provider": "zai",
        "mode": "api_key"
      }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "zai": {
          "baseUrl": "https://open.bigmodel.cn/api/paas/v4",
        "api": "openai-completions",
        "models": [
          {
            "id": "glm-5",
            "name": "GLM-5",
            "reasoning": true,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 204800,
            "maxTokens": 131072
          },
            {
            "id": "glm-4.7",
            "name": "GLM-4.7",
            "reasoning": true,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 204800,
            "maxTokens": 131072
          },
          {
            "id": "glm-4.7-flash",
            "name": "GLM-4.7 Flash",
            "reasoning": true,
            "input": [
                "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 204800,
            "maxTokens": 131072
          },
          {
            "id": "glm-4.7-flashx",
            "name": "GLM-4.7 FlashX",
            "reasoning": true,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
                "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 204800,
            "maxTokens": 131072
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "zai/glm-4.7"
      },
      "models": {
        "zai/glm-5": {
          "alias": "GLM"
        },
        "zai/glm-4.7": {}
      },
      "workspace": "/root/.openclaw/workspace",
      "compaction": {
          "mode": "safeguard"
      },
      "maxConcurrent": 4,
      "subagents": {
        "maxConcurrent": 8
      }
    }
  },
  "tools": {
    "profile": "coding",
    "web": {
      "search": {
        "enabled": false
      },
      "fetch": {
        "enabled": true
      }
    }
  },
  "messages": {
      "ackReactionScope": "group-mentions"
  },
  "commands": {
    "native": "auto",
    "nativeSkills": "auto",
    "restart": true,
    "ownerDisplay": "raw"
  },
  "session": {
    "dmScope": "per-channel-peer"
  },
  "channels": {
    "feishu": {
      "appId": "${FEISHU_APP_ID}",
      "appSecret": "${FEISHU_APP_SECRET}",
      "enabled": true,
      "connectionMode": "websocket",
      "dmPolicy": "pairing",
      "groupPolicy": "open",
      "requireMention": true
    }
      },
  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "lan",
    "controlUi": {
      "allowedOrigins": [
        "http://localhost:18789",
        "http://127.0.0.1:18789",
        "http://公网ip:18789"
      ],
      "allowInsecureAuth": true,
      "dangerouslyDisableDeviceAuth": true
    },
    "auth": {
      "mode": "token",
      "token": "${GATEWAY_TOKEN}"
    },
      "tailscale": {
      "mode": "off",
      "resetOnExit": false
    }
  },
  "plugins": {
    "enabled": true,
    "allow": [
      "feishu"
    ],
    "entries": {
      "feishu": {
        "enabled": true
      }
    }
  }
}
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐