Back to home
Advanced. Technical knowledge required

DIY Setup Guide

This guide is for developers comfortable with CLI tools, server administration, and debugging. If this looks intimidating, consider our done for you setup.

Prefer to skip the hassle?

We handle all of this for you. One payment, no coding, delivered within 24 hours.

1Prerequisites

  • Node.js >= 22.x installed
  • pnpm package manager
  • Git CLI configured
  • VPS with Ubuntu 22.04+ (2GB RAM minimum)
  • SSH access to your server
  • Domain or static IP (recommended)

2Clone and Configure

git clone https://github.com/openclaw/openclaw.git
cd openclaw
cp .env.example .env
pnpm install

3Environment Variables

  • OPENAI_API_KEY or ANTHROPIC_API_KEY
  • TELEGRAM_BOT_TOKEN (if using Telegram)
  • DISCORD_BOT_TOKEN (if using Discord)
  • DATABASE_URL (SQLite or PostgreSQL)
  • SESSION_SECRET (random 32+ char string)

4Gateway Configuration

# In config/gateway.json
{
  "port": 18789,
  "protocol": "wss",
  "sandbox": {
    "mode": "non main",
    "allowedOrigins": ["your-domain.com"]
  }
}

5Systemd Service Setup

# /etc/systemd/system/openclaw.service
[Unit]
Description=OpenClaw Service
After=network.target

[Service]
Type=simple
User=openclaw
WorkingDirectory=/opt/openclaw
ExecStart=/usr/bin/node dist/index.js
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

6OAuth2 Persistence

  • Configure oauth.json with provider credentials
  • Set up token refresh handlers
  • Handle EBADF errors in PTY spawn
  • Configure WSS gateway on port 18789
  • Test connection with health check endpoint

Still stuck? Our setup service handles all of this for you.