Self-Hosted Deployment
Run OpenClaw directly on a Linux VPS or bare-metal server without Docker or Kubernetes. This is the simplest path to production — ideal for individual developers, small teams, and environments where you want full control without container overhead.
Server Requirements
| Component | Minimum | Recommended |
|---|---|---|
| OS | Ubuntu 20.04 / Debian 11 / AlmaLinux 9 | Ubuntu 22.04 LTS |
| RAM | 512MB | 4GB (more for Ollama local models) |
| CPU | 1 vCPU | 2-4 vCPU |
| Disk | 10GB | 40GB SSD |
| Python | 3.10+ | 3.12 |
| Network | Outbound HTTPS | Static IP + domain name for API access |
Installation on Ubuntu 22.04
# Update system
sudo apt update && sudo apt upgrade -y
# Install Python 3.12
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt install python3.12 python3.12-venv python3.12-dev -y
# Install system dependencies
sudo apt install redis-server nginx git curl -y
# Create service user (never run OpenClaw as root)
sudo useradd --system --shell /bin/bash --home /opt/openclaw --create-home openclaw
# Switch to openclaw user
sudo -u openclaw -i# As openclaw user: create venv and install
python3.12 -m venv /opt/openclaw/venv
source /opt/openclaw/venv/bin/activate
pip install --upgrade pip
pip install openclaw[redis,postgres]==1.5.2
# Verify installation
openclaw --versionProduction Configuration
# Create config directory
mkdir -p /opt/openclaw/config /opt/openclaw/data /opt/openclaw/logs
# Create config file (as root, then restrict permissions)
sudo tee /opt/openclaw/config/config.yaml <<'EOF'
openclaw_env: production
log_level: INFO
log_format: json
log_file: /opt/openclaw/logs/openclaw.log
llm:
provider: openai
model: gpt-4o-mini
cache:
enabled: true
backend: redis
redis_url: "redis://127.0.0.1:6379/0"
ttl: 3600
database:
url: "sqlite:////opt/openclaw/data/openclaw.db"
server:
host: 127.0.0.1 # Only listen on loopback; Nginx proxies externally
port: 8080
workers: 4
budget:
max_cost_per_task: 0.50
daily_token_limit: 500000
EOF
# Restrict config file permissions
sudo chmod 600 /opt/openclaw/config/config.yaml
sudo chown openclaw:openclaw /opt/openclaw/config/config.yaml# Store API keys in /etc/environment or a .env file owned by openclaw
sudo tee /opt/openclaw/config/.env <<'EOF'
OPENAI_API_KEY=sk-your-key
OPENCLAW_SECRET_KEY=$(openssl rand -hex 32)
EOF
sudo chmod 600 /opt/openclaw/config/.env
sudo chown openclaw:openclaw /opt/openclaw/config/.envSystemd Service
Run OpenClaw as a systemd service so it auto-starts on reboot and restarts on crash:
# /etc/systemd/system/openclaw.service
[Unit]
Description=OpenClaw AI Agent Service
After=network.target redis.service
Requires=redis.service
[Service]
Type=exec
User=openclaw
Group=openclaw
WorkingDirectory=/opt/openclaw
EnvironmentFile=/opt/openclaw/config/.env
ExecStart=/opt/openclaw/venv/bin/openclaw serve --config /opt/openclaw/config/config.yaml
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal
# Security hardening
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=strict
ReadWritePaths=/opt/openclaw/data /opt/openclaw/logs
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclawNginx Reverse Proxy with TLS
# /etc/nginx/sites-available/openclaw
server {
listen 80;
server_name api.yourcompany.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name api.yourcompany.com;
ssl_certificate /etc/letsencrypt/live/api.yourcompany.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.yourcompany.com/privkey.pem;
# Rate limiting
limit_req_zone $binary_remote_addr zone=openclaw:10m rate=30r/m;
limit_req zone=openclaw burst=10 nodelay;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 120s; # Allow long-running agent tasks
}
}# Install Certbot and get TLS certificate
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d api.yourcompany.com
# Enable the site and reload Nginx
sudo ln -s /etc/nginx/sites-available/openclaw /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginxUpdating OpenClaw
# Stop service during update
sudo systemctl stop openclaw
# Activate venv and upgrade
sudo -u openclaw /opt/openclaw/venv/bin/pip install --upgrade openclaw
# Run any necessary db migrations
sudo -u openclaw /opt/openclaw/venv/bin/openclaw db migrate
# Restart
sudo systemctl start openclaw
sudo systemctl status openclawHardware Requirements
Self-hosted OpenClaw deployments using cloud LLMs (Anthropic, OpenAI APIs) have minimal hardware requirements — the agent process itself is lightweight. A single-core virtual machine with 512MB RAM handles a low-traffic production deployment. For higher concurrency, plan for approximately 256MB per concurrent agent run plus shared overhead. If you're running a local LLM alongside the agent (Ollama, vLLM), hardware requirements scale dramatically with model size. A 7B parameter model needs 8GB GPU RAM at minimum; a 70B model needs 40-80GB. Size your hardware to the local LLM requirements, not the agent process requirements.
Choose your deployment OS based on operational familiarity. Ubuntu LTS and Debian are the most tested platforms; RHEL/Rocky Linux is appropriate for enterprise environments with existing Red Hat footprint. Avoid non-LTS distributions for production — short support windows mean you'll need OS upgrades more frequently, increasing operational overhead and change risk. Keep your OS patched on a regular cadence — monthly patch application for production systems is a reasonable baseline.
Process Management
Use systemd to manage the OpenClaw agent process on Linux. Create a systemd service unit that defines the user to run as (not root), the environment file for secrets injection, restart policy (always restart unless explicitly stopped), and resource limits (CPUQuota, MemoryMax). Systemd handles automatic restart on crash, startup ordering, and logging to journald. This is far more reliable than running the agent in a screen or tmux session, which fails silently on server reboots and doesn't provide proper resource accounting. A well-configured systemd service makes your agent as operationally solid as any other system service.
Backup and Disaster Recovery
Back up agent memory directories and configuration files on a regular schedule. Memory directories contain the persistent context that gives your agents continuity across restarts — losing them means agents lose their accumulated memory. If your agents are stateless (no persistent memory), focus on backing up configuration files and any generated outputs you want to retain. Test restores periodically — a backup that has never been verified in a restore procedure provides false confidence. The goal is recovery time: for most self-hosted deployments, a recovery target of 1 hour is achievable with properly documented procedures and regularly tested backups.
Quickstart Checklist
Follow this checklist for a new self-hosted production deployment: install OpenClaw with pip in a dedicated virtualenv; create a systemd service unit file; configure the .env secrets file with owner:600 permissions; set up logrotate for the agent log directory; configure firewall rules to block direct inbound access (route through your reverse proxy); test the agent manually before enabling the systemd service; enable the service and verify it starts automatically on boot with sudo systemctl enable --now openclaw-agent. Document each step you take in a runbook — your future self at 2am during an incident will thank you.