Skip to main content

OpenClaw on DigitalOcean

目标

在 DigitalOcean 上以 **6/(或保留价6/月**(或保留价 4/月)运行持久化 OpenClaw Gateway。 如果你想要 $0/月 且不介意 ARM + provider 特有配置,见 Oracle Cloud guide

成本对比(2026)

ProviderPlanSpecsPrice/moNotes
Oracle CloudAlways Free ARMup to 4 OCPU, 24GB RAM$0ARM,容量有限/注册有坑
HetznerCX222 vCPU, 4GB RAM€3.79 (~$4)最便宜付费选项
DigitalOceanBasic1 vCPU, 1GB RAM$6UI 简单,文档完善
VultrCloud Compute1 vCPU, 1GB RAM$6机房多
LinodeNanode1 vCPU, 1GB RAM$5现属 Akamai
选择建议:
  • DigitalOcean:最简单的 UX + 可预测(本指南)
  • Hetzner:价格/性能更好(见 Hetzner guide
  • Oracle Cloud:可 $0/月,但更折腾且仅 ARM(见 Oracle guide

前置条件

1) 创建 Droplet

  1. 登录 DigitalOcean
  2. 点击 Create → Droplets
  3. 选择:
    • Region: 离你最近(或用户最近)
    • Image: Ubuntu 24.04 LTS
    • Size: Basic → Regular → $6/mo(1 vCPU,1GB RAM,25GB SSD)
    • Authentication: SSH key(推荐)或密码
  4. 点击 Create Droplet
  5. 记下 IP 地址

2) 通过 SSH 连接

ssh root@YOUR_DROPLET_IP

3) 安装 OpenClaw

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

# 安装 Node.js 22
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs

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

# 验证
openclaw --version

4) 运行 Onboarding

openclaw onboard --install-daemon
向导会引导完成:
  • 模型认证(API keys 或 OAuth)
  • 频道设置(Telegram、WhatsApp、Discord 等)
  • Gateway token(自动生成)
  • Daemon 安装(systemd)

5) 验证 Gateway

# 检查状态
openclaw status

# 检查服务
systemctl --user status openclaw-gateway.service

# 查看日志
journalctl --user -u openclaw-gateway.service -f

6) 访问 Dashboard

Gateway 默认绑定在 loopback。访问 Control UI: 选项 A:SSH 隧道(推荐)
# 在本地机器
ssh -L 18789:localhost:18789 root@YOUR_DROPLET_IP

# 然后打开:http://localhost:18789
选项 B:Tailscale Serve(HTTPS,loopback-only)
# 在 droplet 上
curl -fsSL https://tailscale.com/install.sh | sh
tailscale up

# 配置 Gateway 使用 Tailscale Serve
openclaw config set gateway.tailscale.mode serve
openclaw gateway restart
打开:https://<magicdns>/ 注意:
  • Serve 让 Gateway 保持 loopback-only,并通过 Tailscale 身份头认证。
  • 若要 token/password 认证,设置 gateway.auth.allowTailscale: falsegateway.auth.mode: "password"
选项 C:Tailnet bind(不使用 Serve)
openclaw config set gateway.bind tailnet
openclaw gateway restart
打开:http://<tailscale-ip>:18789(需要 token)。

7) 连接你的频道

Telegram

openclaw pairing list telegram
openclaw pairing approve telegram <CODE>

WhatsApp

openclaw channels login whatsapp
# 扫描二维码
其它 providers 见 Channels

1GB RAM 优化

$6 的 droplet 只有 1GB RAM。保持稳定运行建议:

添加 swap(推荐)

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

使用更轻量的模型

若出现 OOM,考虑:
  • 用 API 模型(Claude、GPT)替代本地模型
  • agents.defaults.model.primary 设为更小模型

监控内存

free -h
htop

持久化

所有状态位于:
  • ~/.openclaw/ — 配置、凭据、会话数据
  • ~/.openclaw/workspace/ — workspace(SOUL.md、memory 等)
这些会在重启后保留。定期备份:
tar -czvf openclaw-backup.tar.gz ~/.openclaw ~/.openclaw/workspace

Oracle Cloud 免费替代

Oracle Cloud 提供 Always Free ARM 实例,性能显著高于上述付费方案 —— $0/月。
What you getSpecs
4 OCPUsARM Ampere A1
24GB RAM足够使用
200GB storage块存储
Forever free永久免费
注意事项:
  • 注册可能比较折腾(失败就重试)
  • ARM 架构 — 大多可用,但部分二进制需要 ARM 构建
完整指南见 Oracle Cloud。注册与排障提示见这个 社区指南

Troubleshooting

Gateway 无法启动

openclaw gateway status
openclaw doctor --non-interactive
journalctl -u openclaw --no-pager -n 50

端口占用

lsof -i :18789
kill <PID>

内存不足

# 查看内存
free -h

# 添加更多 swap
# 或升级到 $12/mo droplet(2GB RAM)

See Also