Skip to content

腾讯云部署 OpenClaw

在腾讯云 CVM 或 Lighthouse 上运行持久化的 OpenClaw Gateway,让你的龙虾 24 小时在线。

前置条件

  • 腾讯云账号(注册
  • SSH 工具(PuTTY、终端或腾讯云控制台的网页 SSH)
  • 约 20 分钟

第一步:创建实例

推荐配置:

配置推荐值
产品CVM 标准型 S5 或 Lighthouse 2 核 2 GB
镜像Ubuntu Server 22.04 LTS 64 位
系统盘40 GB SSD
网络默认 VPC,分配公网 IP
计费模式按量付费(测试)或包年包月(长期)

Lighthouse 用户:Lighthouse 已预配置防火墙,跳过下方"安全组"步骤,直接在 Lighthouse 控制台的"防火墙"页面放行端口即可。

创建步骤:

  1. 登录腾讯云控制台
  2. 新建 CVM,选择上表配置
  3. 登录方式选"SSH 密钥"(推荐)或密码
  4. 记下实例的公网 IP

第二步:配置安全组

在腾讯云控制台 → 安全组 → 入站规则,放行以下端口:

端口协议用途
22TCPSSH 远程登录
80TCPHTTP(Nginx,可选)
443TCPHTTPS(Nginx + SSL,可选)
18789TCPOpenClaw Gateway Web UI(仅测试用,生产建议用 Nginx 代理)

生产环境:18789 端口不必对外开放,用 Nginx 反向代理到 80/443 更安全。

第三步:安装 Node.js 和 OpenClaw

SSH 登录实例后执行:

bash
# 更新系统
apt update && apt upgrade -y

# 安装 Node.js 24(推荐)
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt install -y nodejs

# 验证
node -v   # 应输出 v24.x.x

# 安装 OpenClaw
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw --version

第四步:运行引导配置

bash
openclaw onboard --install-daemon

向导会依次引导你完成:模型 API Key 配置 → 频道选择 → Gateway 令牌生成 → systemd 守护进程安装。

完成后验证 Gateway 状态:

bash
openclaw status
systemctl --user status openclaw-gateway.service

第五步(可选):Nginx 反向代理

如果你想通过域名访问 Control UI,或不想暴露 18789 端口:

bash
apt install -y nginx

# 创建 Nginx 配置
cat > /etc/nginx/sites-available/openclaw << 'EOF'
server {
    listen 80;
    server_name your-domain.com;  # 替换为你的域名或公网 IP

    location / {
        proxy_pass http://127.0.0.1:18789;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
EOF

ln -s /etc/nginx/sites-available/openclaw /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

配置好后通过 http://your-domain.com 访问 Control UI。

添加 Swap(2 GB 内存以下推荐)

bash
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab

故障排查

Gateway 无法启动 — 运行 openclaw doctor --non-interactive,用 journalctl --user -u openclaw-gateway.service -n 50 查看详细日志。

端口无法访问 — 检查腾讯云安全组入站规则是否放行对应端口;确认系统防火墙(ufw status)未拦截。

内存不足 / OOM — 确认 Swap 已激活(free -h);或升级到 4 GB 内存实例。

openclaw 命令找不到 — 检查 PATH:npm prefix -g,将 $(npm prefix -g)/bin 加入 ~/.bashrc

下一步