⚠️This guide requires advanced technical knowledge. Average setup time: 2-4 hours.Or let us do it for $99/month →
clawdbot 安装 · openclaw 安装 · clawdbot 配置

Clawdbot DIY Installation Guide

Complete technical documentation for self-hosting clawdbot on your own infrastructure. This guide assumes familiarity with Linux, Node.js, and server administration.

🛑 Prerequisites Checklist

Before proceeding, ensure you have:

  • Node.js v18.0+ installed with npm package manager (verify with node -v and npm -v)
  • Git CLI installed and configured with SSH keys for GitHub authentication
  • VPS or Cloud Server with root/sudo access (Ubuntu 22.04 LTS recommended, minimum 2GB RAM)
  • Domain name with DNS A record pointing to your server IP address
  • PostgreSQL 14+ database instance (local or managed like Neon, Supabase)
  • Redis 6+ for session management and caching
  • Anthropic API Key with sufficient credits for Claude API access
  • Understanding of MCP (Model Context Protocol) architecture and stdio transport

Installation Steps

Step 1: Server Preparation

SSH into your server and update system packages:

ssh root@your-server-ip

# Update system packages
sudo apt update && sudo apt upgrade -y

# Install required dependencies
sudo apt install -y curl wget git build-essential

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

# Verify installation
node -v  # Should output v18.x.x
npm -v   # Should output 9.x.x or higher
Step 2: Install PostgreSQL & Redis

Set up database and caching services:

# Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib

# Start PostgreSQL service
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Create database and user
sudo -u postgres psql << EOF
CREATE USER clawdbot WITH PASSWORD 'your_secure_password';
CREATE DATABASE clawdbot_db OWNER clawdbot;
GRANT ALL PRIVILEGES ON DATABASE clawdbot_db TO clawdbot;
EOF

# Install Redis
sudo apt install -y redis-server

# Configure Redis for production
sudo sed -i 's/supervised no/supervised systemd/' /etc/redis/redis.conf
sudo systemctl restart redis
sudo systemctl enable redis

# Verify Redis is running
redis-cli ping  # Should return PONG
Step 3: Clone and Configure Clawdbot

Clone the repository and set up environment variables:

# Clone the repository
cd /opt
sudo git clone https://github.com/clawdbot/clawdbot.git
cd clawdbot

# Install dependencies (may take several minutes)
npm install --legacy-peer-deps

# Create environment configuration
cp .env.example .env
nano .env

Configure the following environment variables in .env:

# Required API Keys
ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxx

# Database Configuration
DATABASE_URL=postgresql://clawdbot:your_secure_password@localhost:5432/clawdbot_db

# Redis Configuration
REDIS_URL=redis://localhost:6379

# MCP Server Configuration
MCP_TRANSPORT=stdio
MCP_SERVER_PORT=3100

# Security
JWT_SECRET=generate_a_64_character_random_string_here
ENCRYPTION_KEY=generate_another_32_character_string

# Optional: Integration Keys
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
DISCORD_BOT_TOKEN=your_discord_bot_token
WHATSAPP_API_KEY=your_whatsapp_business_api_key

# Server Configuration
NODE_ENV=production
PORT=3000
Step 4: Configure MCP (Model Context Protocol)

Set up the MCP server configuration for Claude integration:

# Create MCP configuration directory
mkdir -p ~/.config/clawdbot

# Create claude_desktop_config.json
cat > ~/.config/clawdbot/claude_desktop_config.json << 'EOF'
{
  "mcpServers": {
    "clawdbot": {
      "command": "node",
      "args": ["/opt/clawdbot/dist/mcp-server.js"],
      "transport": "stdio",
      "env": {
        "NODE_ENV": "production",
        "LOG_LEVEL": "info"
      }
    }
  },
  "globalShortcut": "Ctrl+Shift+Space",
  "theme": "system"
}
EOF

# Set proper permissions
chmod 600 ~/.config/clawdbot/claude_desktop_config.json
Step 5: Database Migration & Build

Initialize database schema and build production assets:

# Generate Prisma client
npx prisma generate

# Run database migrations
npx prisma migrate deploy

# Build production bundle
npm run build

# Verify build output
ls -la dist/  # Should contain compiled JavaScript files
Step 6: Configure systemd Service

Create a systemd service for automatic startup and process management:

# Create systemd service file
sudo cat > /etc/systemd/system/clawdbot.service << 'EOF'
[Unit]
Description=Clawdbot AI Assistant
After=network.target postgresql.service redis.service

[Service]
Type=simple
User=root
WorkingDirectory=/opt/clawdbot
ExecStart=/usr/bin/node dist/server.js
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=clawdbot
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd and start service
sudo systemctl daemon-reload
sudo systemctl enable clawdbot
sudo systemctl start clawdbot

# Check service status
sudo systemctl status clawdbot
Step 7: Configure Nginx Reverse Proxy with SSL

Set up Nginx as reverse proxy with Let's Encrypt SSL certificate:

# Install Nginx and Certbot
sudo apt install -y nginx certbot python3-certbot-nginx

# Create Nginx configuration
sudo cat > /etc/nginx/sites-available/clawdbot << 'EOF'
server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }
}
EOF

# Enable site and remove default
sudo ln -s /etc/nginx/sites-available/clawdbot /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default

# Test and reload Nginx
sudo nginx -t
sudo systemctl reload nginx

# Obtain SSL certificate
sudo certbot --nginx -d your-domain.com --non-interactive --agree-tos -m your@email.com
Step 8: Configure Firewall

Secure your server with UFW firewall rules:

# Enable UFW firewall
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow SSH (important: don't lock yourself out!)
sudo ufw allow ssh

# Allow HTTP and HTTPS
sudo ufw allow 'Nginx Full'

# Enable firewall
sudo ufw enable

# Verify rules
sudo ufw status verbose
Step 9: Verify Installation

Test your clawdbot installation:

# Check all services are running
sudo systemctl status clawdbot
sudo systemctl status nginx
sudo systemctl status postgresql
sudo systemctl status redis

# Test API endpoint
curl -X GET https://your-domain.com/api/health

# Check logs for any errors
sudo journalctl -u clawdbot -f
Common Issues & Troubleshooting

Error: EACCES permission denied

Fix: Run sudo chown -R $USER:$USER /opt/clawdbot

Error: Cannot connect to PostgreSQL

Fix: Check DATABASE_URL format and ensure PostgreSQL is running with sudo systemctl status postgresql

Error: MCP server failed to start

Fix: Verify claude_desktop_config.json syntax and file permissions

Error: npm install fails with ERESOLVE

Fix: Use npm install --legacy-peer-deps flag

Too Complicated?

Skip all these steps. We'll deploy Clawdbot for you in 24 hours.