AI Agents

How to self-host OpenClaw on a VPS

OpenClaw is an MIT-licensed AI assistant platform that connects to 23+ messaging channels — WhatsApp, Telegram, Slack, Discord, and more. Running it on your own VPS means your data stays on your hardware, you pick the LLM provider, and you pay only for compute. This guide covers installation, BYOK configuration, channel setup, and production HTTPS with Caddy.

Requirements

  • Ubuntu 22.04+ / Debian 12 / macOS / Windows WSL2
  • Node.js 22.19+ or Node.js 24 (LTS recommended)
  • A VPS with at least 1 GB RAM and a public IP address
  • An API key for Claude 4, GPT-4o, Gemini, or DeepSeek (BYOK)
  • A domain or subdomain pointing at your VPS (for HTTPS)

Step 1 — Install Node.js 22

# Install Node.js 22 LTS via NodeSource
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

node --version   # should print v22.x.x or higher

Step 2 — Install OpenClaw

The quickest path is the global npm package with the built-in daemon installer:

npm install -g openclaw@latest
openclaw onboard --install-daemon

The --install-daemon flag writes a systemd unit so OpenClaw starts on boot automatically. You can still run it manually with openclaw start.

Step 3 — Add your BYOK API key

OpenClaw supports multiple providers. Set the key for the model you want to use:

openclaw config set llm.provider anthropic
openclaw config set llm.apiKey sk-ant-...
openclaw config set llm.model claude-sonnet-4-5

Step 4 — Connect messaging channels

OpenClaw supports 23+ channels. Here are the two most common:

Telegram

# 1. Create a bot with @BotFather in Telegram — copy the token
# 2. Register it with OpenClaw:
openclaw channels add telegram --token 123456789:ABCdef...

WhatsApp (via Meta Business API)

# Follow Meta's Business API setup to get your token and phone number ID
openclaw channels add whatsapp \
  --token EAAG... \
  --phone-number-id 123456789012345

Run openclaw channels list to see all supported integrations including Slack, Discord, Signal, and SMS.

Step 5 — HTTPS with Caddy

Caddy automatically provisions and renews TLS certificates via Let's Encrypt. Install it and create a simple Caddyfile:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update && sudo apt install caddy

Replace agent.yourdomain.com with your actual subdomain and ensure port 80/443 are open in your firewall. OpenClaw defaults to port 3000.

Step 6 — Verify and maintain

# Check status
openclaw status

# View logs
journalctl -u openclaw -f

# Update to the latest version
npm install -g openclaw@latest
sudo systemctl restart openclaw

Prefer not to manage it yourself?

AgentOcean manages OpenClaw on a dedicated VPS — HTTPS, daily backups, monitoring, and one-click updates — without you touching a terminal.

Related