---
title: "How to Setup OpenClaw AI Assistant on a Linux Server - Complete Guide"
description: "Learn how to install and configure OpenClaw, an open-source AI assistant framework, on your Linux server. Step-by-step guide covering installation, configuration, Docker setup, and connecting via WhatsApp, Telegram, or Discord."
date: "2026-02-04"
author: "Jayesh Jain"
category: "Artificial Intelligence"
tags: ["OpenClaw", "AI Assistant", "Linux Server", "Self-Hosted AI", "ChatGPT Alternative", "Open Source AI"]
keywords: "OpenClaw setup, install OpenClaw Linux, self-hosted AI assistant, OpenClaw tutorial, AI assistant server setup, OpenClaw WhatsApp, OpenClaw Telegram, open source AI assistant, Claude API setup, OpenClaw Docker"
featuredImage: "/blog/how-to-setup-openclaw-on-linux-server.png"
cta: "Need help setting up OpenClaw for your business?"
ctaDescription: "Contact our team for OpenClaw Setup and integration services."
---

# 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

```bash
node -v
# Should output v22.x.x or higher
```

If you need to install Node.js 22:

```bash
# Using NodeSource
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo 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:

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

This script:
1. Installs the **openclaw** CLI globally via npm
2. Runs the interactive onboarding wizard
3. Sets up the Gateway daemon

### Method 2: Manual npm Install

If you prefer manual control:

```bash
# Install globally
npm install -g openclaw@latest

# Run onboarding
openclaw onboard --install-daemon
```

### Method 3: Docker (Containerized)

For isolated deployments:

```bash
# Clone the repository
git clone https://github.com/openclaw/openclaw.git
cd openclaw

# Run Docker setup
./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

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

You'll see output like:

```
Installing OpenClaw...
✓ Node.js version check passed (v22.x.x)
✓ Installing openclaw globally...
✓ OpenClaw installed successfully!

Starting 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:

```
? Select your AI provider: Anthropic
? Enter your Anthropic API key: sk-ant-xxxxx
```

### Step 3: Set Up Messaging Channels (Optional)

OpenClaw can connect to messaging platforms:

**WhatsApp:**
```bash
openclaw channels login
# Scan the QR code with your WhatsApp app
```

**Telegram:**
```bash
openclaw channels add --channel telegram --token "YOUR_BOT_TOKEN"
```

**Discord:**
```bash
openclaw channels add --channel discord --token "YOUR_BOT_TOKEN"
```

### Step 4: Start the Gateway

```bash
# Start the daemon
openclaw gateway start

# Check status
openclaw status
```

### Step 5: Access the Dashboard

```bash
# Open the dashboard (generates a tokenized URL)
openclaw 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

```json5
{
  // AI provider settings
  agents: {
    defaults: {
      workspace: "~/.openclaw/workspace",
      model: "anthropic/claude-sonnet-4-20250514"
    }
  },
  
  // Gateway settings
  gateway: {
    port: 18789,
    bind: "localhost",
    auth: {
      token: "your-secure-token"
    }
  },
  
  // WhatsApp settings
  channels: {
    whatsapp: {
      allowFrom: ["+1234567890"]  // Your phone number
    }
  }
}
```

### Expose to Network (with Authentication)

To access from other devices:

```json5
{
  gateway: {
    bind: "lan",  // or "0.0.0.0"
    auth: {
      token: "your-secure-random-token"
    }
  }
}
```

⚠️ **Always use authentication** when exposing to a network!

---

## Docker Setup (Alternative)

For production deployments, Docker provides better isolation.

### Quick Docker Setup

```bash
git clone https://github.com/openclaw/openclaw.git
cd openclaw
./docker-setup.sh
```

### Mount Your Code Directory

To give OpenClaw access to your projects:

```bash
export OPENCLAW_EXTRA_MOUNTS="/path/to/your/code:/home/node/code:rw"
./docker-setup.sh
```

### Docker Compose Commands

```bash
# Start
docker compose up -d openclaw-gateway

# Stop
docker compose down

# View logs
docker compose logs -f openclaw-gateway

# Restart
docker compose restart openclaw-gateway
```

---

## Useful Commands

```bash
# Check installation health
openclaw doctor

# View gateway status
openclaw status

# Check gateway health
openclaw health

# View logs
openclaw logs

# Restart gateway
openclaw gateway restart

# Update OpenClaw
openclaw update
```

---

## Connecting from Mobile

### WhatsApp
1. Run **openclaw channels login**
2. Scan the QR code with WhatsApp
3. Send a message to yourself - OpenClaw responds!

### Telegram
1. Create a bot via [@BotFather](https://t.me/botfather)
2. Add the token: **openclaw channels add --channel telegram --token "TOKEN"**
3. Start chatting with your bot

---

## Security Best Practices

1. **Always use authentication** - Set **gateway.auth.token**
2. **Use HTTPS** - Put behind a reverse proxy (nginx/Caddy)
3. **Limit access** - Use **allowFrom** in channel configs
4. **Regular updates** - Run **openclaw update** regularly
5. **Backup config** - Keep **~/.openclaw/** backed up

---

## Troubleshooting

### "openclaw: command not found"

Add npm's global bin to your PATH:

```bash
export PATH="$(npm prefix -g)/bin:$PATH"
# Add to ~/.bashrc or ~/.zshrc for persistence
```

### Permission Errors

```bash
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
export PATH="$HOME/.npm-global/bin:$PATH"
```

### Gateway Won't Start

```bash
# Check for issues
openclaw doctor

# View detailed logs
openclaw 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:

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

---

## Resources

- [OpenClaw GitHub](https://github.com/openclaw/openclaw)
- [Official Documentation](https://docs.openclaw.ai)
- [Discord Community](https://discord.com/invite/clawd)
- [ClaHub Skills](https://clawhub.com)
