Home Tutorials Categories Skills About
ZH EN JA KO
Installation

Complete Guide to Deploying OpenClaw on a VPS

· 12 min read

OpenClaw is an open-source, self-hosted AI assistant that connects to WhatsApp, Telegram, Discord, and many other chat platforms. To keep it online around the clock, the best approach is deploying it on a VPS (Virtual Private Server). This tutorial takes you through the entire process, starting from choosing a VPS. For more information, visit OpenClaw.

Choosing a VPS

OpenClaw has modest server requirements. Here are the recommended minimum specs:

Resource Minimum Recommended
CPU 1 core 2 cores
RAM 2 GB 4 GB
Storage 20 GB SSD 40 GB SSD
OS Ubuntu 22.04 Ubuntu 24.04
Network Static public IP Static public IP

If you also plan to run Ollama local models on the same server, you'll need at least 8 GB of RAM.

Popular VPS providers include Vultr, DigitalOcean, Linode, BandwagonHost, and RackNerd. Choosing a data center close to your location will give you lower latency.

Step 1: Initialize the Server

After purchasing your VPS, connect via SSH:

ssh root@your-server-ip

Start by updating the system and installing essential tools:

apt update && apt upgrade -y
apt install -y curl wget git build-essential

For security, create a non-root user to run OpenClaw:

adduser openclaw
usermod -aG sudo openclaw

Switch to the new user:

su - openclaw

All subsequent steps should be performed under this user.

Step 2: Install Node.js 22

OpenClaw requires Node.js 22 or later. Install it using the NodeSource repository:

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

Verify the installed version:

node --version  # Should show v22.x.x
npm --version

If you prefer using a version manager, you can install via nvm instead:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 22
nvm use 22

Step 3: Install OpenClaw

Install OpenClaw globally via npm:

npm install -g openclaw@latest

Run the onboarding wizard to complete the initial setup:

openclaw onboard

The wizard will walk you through:

  1. Selecting an AI model provider (e.g., Anthropic Claude, OpenAI)
  2. Entering the corresponding API key
  3. Configuring chat channels (you can add these later)
  4. Completing the basic setup

Once initialization is complete, the configuration is saved at ~/.config/openclaw/openclaw.json5.

Step 4: Test the Gateway

Start the Gateway manually to confirm everything is working:

openclaw gateway start

In another terminal window, run the diagnostic tool:

openclaw doctor

If all checks pass, OpenClaw is ready to go. Press Ctrl+C to stop the Gateway — next, we'll set it up as a system service for automatic startup.

Step 5: Configure a systemd Service for 24/7 Uptime

Create a systemd service file so OpenClaw runs continuously in the background and automatically restarts after a server reboot:

sudo nano /etc/systemd/system/openclaw.service

Paste in the following:

[Unit]
Description=OpenClaw AI Assistant Gateway
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=openclaw
Group=openclaw
ExecStart=/usr/bin/openclaw gateway start
Restart=always
RestartSec=10
Environment=NODE_ENV=production

# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/home/openclaw

[Install]
WantedBy=multi-user.target

Note: If you installed Node.js through nvm, the ExecStart path needs to point to the actual binary location. Run which openclaw to find it.

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw

Check the service status:

sudo systemctl status openclaw

View real-time logs:

sudo journalctl -u openclaw -f

Step 6: Configure the Firewall

Set up basic firewall rules with UFW:

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp      # SSH
sudo ufw allow 80/tcp      # HTTP
sudo ufw allow 443/tcp     # HTTPS
sudo ufw enable

Important: Do not expose port 18789 to the public internet. The OpenClaw Gateway should be served through an Nginx reverse proxy.

Step 7: Set Up Automatic Updates

OpenClaw receives frequent updates. It's a good idea to check for and install them regularly. Create a simple update script:

nano ~/update-openclaw.sh
#!/bin/bash
npm update -g openclaw@latest
sudo systemctl restart openclaw
echo "OpenClaw updated at $(date)" >> ~/openclaw-updates.log
chmod +x ~/update-openclaw.sh

Use crontab to schedule a weekly update check:

crontab -e

Add the following line:

0 4 * * 1 /home/openclaw/update-openclaw.sh

This runs the update script every Monday at 4:00 AM.

Post-Deployment Checklist

After completing all the steps, verify each item:

  • [ ] openclaw doctor — all checks pass
  • [ ] systemctl status openclaw — shows active (running)
  • [ ] Firewall is enabled and port 18789 is not publicly accessible
  • [ ] Chat channels can send and receive messages normally
  • [ ] OpenClaw starts automatically after a server reboot

Wrapping Up

You now have a private AI assistant running 24/7 on your VPS. It can connect to multiple chat platforms simultaneously and respond to you at any time. As a next step, consider setting up an Nginx reverse proxy with SSL certificates for better security. For complete configuration references and advanced features, check the OpenClaw official documentation. Source code and issue tracking are available at the OpenClaw GitHub repository.

OpenClaw is a free, open-source personal AI assistant that supports WhatsApp, Telegram, Discord, and many more platforms