How to Setup OpenClaw AI Assistant on a Linux Server
OpenClaw is a powerful open-source AI assistant framework that lets you run your own AI-powered assistant on any Linux server. Unlike cloud-only solutions, OpenClaw gives you full control over your data while connecting to leading AI models like Claude, GPT-4, and more.
In this guide, we'll walk through setting up OpenClaw on a Linux server from scratch.
What is OpenClaw?
OpenClaw is an open-source AI assistant platform that:
- Runs on your infrastructure — VPS, home server, or cloud VM
- Connects to multiple AI providers — Anthropic Claude, OpenAI, Google, and more
- Integrates with messaging platforms — WhatsApp, Telegram, Discord, Slack, and iMessage
- Provides a web dashboard — Control and chat via browser
- Supports automation — Cron jobs, webhooks, and tool integrations
- Offers sandboxed execution — Safe code execution via Docker
Prerequisites
Before you begin, ensure you have:
- A Linux server (Ubuntu 22.04+, Debian 12+, or similar)
- Node.js 22+ installed
- Root or sudo access
- An API key from an AI provider (Anthropic, OpenAI, etc.)
Check Node.js Version
1node -v 2# Should output v22.x.x or higher
If you need to install Node.js 22:
1# Using NodeSource 2curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - 3sudo apt-get install -y nodejs
Installation Methods
OpenClaw offers multiple installation paths. Choose the one that fits your needs.
Method 1: Quick Install (Recommended)
The fastest way to get started:
1curl -fsSL https://openclaw.ai/install.sh | bash
This script:
- Installs the openclaw CLI globally via npm
- Runs the interactive onboarding wizard
- Sets up the Gateway daemon
Method 2: Manual npm Install
If you prefer manual control:
1# Install globally 2npm install -g openclaw@latest 3 4# Run onboarding 5openclaw onboard --install-daemon
Method 3: Docker (Containerized)
For isolated deployments:
1# Clone the repository 2git clone https://github.com/openclaw/openclaw.git 3cd openclaw 4 5# Run Docker setup 6./docker-setup.sh
The Docker setup:
- Builds the gateway image
- Runs onboarding
- Starts the gateway via Docker Compose
- Generates a secure gateway token
Step-by-Step Setup Guide
Step 1: Run the Installer
1curl -fsSL https://openclaw.ai/install.sh | bash
You'll see output like:
1Installing OpenClaw... 2✓ Node.js version check passed (v22.x.x) 3✓ Installing openclaw globally... 4✓ OpenClaw installed successfully! 5 6Starting onboarding wizard...
Step 2: Configure AI Provider
The onboarding wizard will ask for your AI provider. Choose one:
- Anthropic Claude (recommended) — Best for coding and reasoning
- OpenAI — GPT-4o and GPT-4
- Google AI — Gemini models
- OpenRouter — Access multiple providers
Enter your API key when prompted:
1? Select your AI provider: Anthropic 2? Enter your Anthropic API key: sk-ant-xxxxx
Step 3: Set Up Messaging Channels (Optional)
OpenClaw can connect to messaging platforms:
WhatsApp:
1openclaw channels login 2# Scan the QR code with your WhatsApp app
Telegram:
1openclaw channels add --channel telegram --token "YOUR_BOT_TOKEN"
Discord:
1openclaw channels add --channel discord --token "YOUR_BOT_TOKEN"
Step 4: Start the Gateway
1# Start the daemon 2openclaw gateway start 3 4# Check status 5openclaw status
Step 5: Access the Dashboard
1# Open the dashboard (generates a tokenized URL) 2openclaw dashboard
This opens the web-based Control UI where you can:
- Chat with your AI assistant
- Configure settings
- Monitor sessions
- View logs
Configuration
OpenClaw uses a JSON5 config file at ~/.openclaw/openclaw.json.
Basic Configuration Example
1{ 2 // AI provider settings 3 agents: { 4 defaults: { 5 workspace: "~/.openclaw/workspace", 6 model: "anthropic/claude-sonnet-4-20250514" 7 } 8 }, 9 10 // Gateway settings 11 gateway: { 12 port: 18789, 13 bind: "localhost", 14 auth: { 15 token: "your-secure-token" 16 } 17 }, 18 19 // WhatsApp settings 20 channels: { 21 whatsapp: { 22 allowFrom: ["+1234567890"] // Your phone number 23 } 24 } 25}
Expose to Network (with Authentication)
To access from other devices:
1{ 2 gateway: { 3 bind: "lan", // or "0.0.0.0" 4 auth: { 5 token: "your-secure-random-token" 6 } 7 } 8}
⚠️ Always use authentication when exposing to a network!
Docker Setup (Alternative)
For production deployments, Docker provides better isolation.
Quick Docker Setup
1git clone https://github.com/openclaw/openclaw.git 2cd openclaw 3./docker-setup.sh
Mount Your Code Directory
To give OpenClaw access to your projects:
1export OPENCLAW_EXTRA_MOUNTS="/path/to/your/code:/home/node/code:rw" 2./docker-setup.sh
Docker Compose Commands
1# Start 2docker compose up -d openclaw-gateway 3 4# Stop 5docker compose down 6 7# View logs 8docker compose logs -f openclaw-gateway 9 10# Restart 11docker compose restart openclaw-gateway
Useful Commands
1# Check installation health 2openclaw doctor 3 4# View gateway status 5openclaw status 6 7# Check gateway health 8openclaw health 9 10# View logs 11openclaw logs 12 13# Restart gateway 14openclaw gateway restart 15 16# Update OpenClaw 17openclaw update
Connecting from Mobile
- Run openclaw channels login
- Scan the QR code with WhatsApp
- Send a message to yourself — OpenClaw responds!
Telegram
- Create a bot via @BotFather
- Add the token: openclaw channels add --channel telegram --token "TOKEN"
- Start chatting with your bot
Security Best Practices
- Always use authentication — Set gateway.auth.token
- Use HTTPS — Put behind a reverse proxy (nginx/Caddy)
- Limit access — Use allowFrom in channel configs
- Regular updates — Run openclaw update regularly
- Backup config — Keep ~/.openclaw/ backed up
Troubleshooting
"openclaw: command not found"
Add npm's global bin to your PATH:
1export PATH="$(npm prefix -g)/bin:$PATH" 2# Add to ~/.bashrc or ~/.zshrc for persistence
Permission Errors
1mkdir -p "$HOME/.npm-global" 2npm config set prefix "$HOME/.npm-global" 3export PATH="$HOME/.npm-global/bin:$PATH"
Gateway Won't Start
1# Check for issues 2openclaw doctor 3 4# View detailed logs 5openclaw logs --level debug
Conclusion
OpenClaw provides a powerful, self-hosted alternative to cloud-only AI assistants. With full control over your data and the flexibility to connect multiple AI providers and messaging platforms, it's ideal for developers and businesses who want AI assistance without vendor lock-in.
Key benefits:
- ✅ Self-hosted and open source
- ✅ Connect to Claude, GPT-4, Gemini, and more
- ✅ WhatsApp, Telegram, Discord, Slack integration
- ✅ Web dashboard for easy management
- ✅ Docker support for production deployments
Ready to get started? Run the installer:
1curl -fsSL https://openclaw.ai/install.sh | bash

