跳转到内容

DigitalOcean

在 DigitalOcean Droplet 上运行持久化的 OpenClaw Gateway(网关)。

  • DigitalOcean 账户 (注册)
  • SSH 密钥对(或愿意使用密码认证)
  • 大约 20 分钟
  1. 创建 Droplet

    1. 登录 DigitalOcean
    2. 点击 Create > Droplets
    3. 选择:
      • Region(区域): 距离您最近的区域
      • Image(镜像): Ubuntu 24.04 LTS
      • Size(规格): Basic, Regular, 1 vCPU / 1 GB RAM / 25 GB SSD
      • Authentication(认证): SSH 密钥(推荐)或密码
    4. 点击 Create Droplet 并记录 IP 地址。
  2. 连接并安装

    Terminal window
    ssh root@YOUR_DROPLET_IP
    apt update && apt upgrade -y
    # Install Node.js 24
    curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
    apt install -y nodejs
    # Install OpenClaw
    curl -fsSL https://openclaw.ai/install.sh | bash
    openclaw --version
  3. 运行新手引导

    Terminal window
    openclaw onboard --install-daemon

    向导将引导您完成模型认证、渠道设置、网关令牌生成和守护程序安装(systemd)。

  4. 添加交换空间(推荐用于 1 GB Droplet)

    Terminal window
    fallocate -l 2G /swapfile
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile
    echo '/swapfile none swap sw 0 0' >> /etc/fstab
  5. 验证网关

    bash openclaw status systemctl --user status openclaw-gateway.service journalctl --user -u openclaw-gateway.service -f

  6. 访问控制界面

    网关默认绑定到环回地址。请选择以下选项之一。

    选项 A:SSH 隧道(最简单)

    Terminal window
    # From your local machine
    ssh -L 18789:localhost:18789 root@YOUR_DROPLET_IP

    然后打开 http://localhost:18789

    选项 B:Tailscale Serve

    Terminal window
    curl -fsSL https://tailscale.com/install.sh | sh
    tailscale up
    openclaw config set gateway.tailscale.mode serve
    openclaw gateway restart

    然后从 tailnet 上的任何设备打开 `https://

    /`。

    **选项 C:Tailnet 绑定(不使用 Serve)**
    ```bash
    openclaw config set gateway.bind tailnet
    openclaw gateway restart
    ```
    然后打开 `http://

    :18789`(需要令牌)。

Gateway(网关) 无法启动 — 运行 openclaw doctor --non-interactive 并使用 journalctl --user -u openclaw-gateway.service -n 50 检查日志。

端口已被占用 — 运行 lsof -i :18789 查找进程,然后将其停止。

内存不足 — 使用 free -h 验证交换空间是否处于活动状态。如果仍然遇到内存不足(OOM),请使用基于 API 的模型(Claude、GPT)而不是本地模型,或者升级到 2 GB 的 Droplet。