在 DigitalOcean Droplet 上运行持久化 OpenClaw Gateway,约 $6/月(1 GB Basic 方案)。

前置条件

  • DigitalOcean 账号
  • SSH 密钥对
  • 约 20 分钟

部署步骤

1. 创建 Droplet

  • 镜像:Ubuntu 24.04 LTS
  • 规格:Basic,1 vCPU / 1 GB RAM / 25 GB SSD
  • 认证:SSH key(推荐)

2. 连接并安装

ssh root@YOUR_DROPLET_IP
apt update && apt upgrade -y
 
# 安装 Node.js 24
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt install -y nodejs
 
# 安装 OpenClaw
curl -fsSL https://openclaw.ai/install.sh | bash
 
# 创建非 root 用户
adduser openclaw
usermod -aG sudo openclaw
loginctl enable-linger openclaw
su - openclaw

3. 运行 Onboarding

openclaw onboard --install-daemon

向导引导完成模型认证、channel 配置、gateway token 生成和 systemd daemon 安装。

4. 添加 Swap(1 GB Droplet 推荐)

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

5. 验证

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

访问 Control UI

方式 A:SSH 隧道(最简单)

ssh -L 18789:localhost:18789 root@YOUR_DROPLET_IP
# 浏览器打开 http://localhost:18789

方式 B:Tailscale Serve

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

方式 C:Tailnet 绑定

openclaw config set gateway.bind tailnet
openclaw gateway restart
# 访问 http://<tailscale-ip>:18789

1 GB RAM 优化建议

  • 确保 swap 写入 /etc/fstab 以在重启后保留
  • 优先使用 API 模型(Claude、GPT),不要运行本地 LLM
  • 监控:free -h 和 htop

常见问题

  • Gateway 无法启动:运行 openclaw doctor --non-interactive
  • 端口占用:lsof -i :18789
  • OOM:验证 swap 是否激活,或升级到 2 GB Droplet

相关链接