> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch37-deployment/37.1-local-deployment.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 37.1 Local Deployment

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~195k tokens, Output \~5k tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

Local deployment is the most common way to use OpenClaw — running Gateway on a personal computer and interacting with it through the console UI or native clients.

## 37.1.1 Global npm Installation

The simplest installation method is through global npm installation:

```bash
npm install -g openclaw
```

After installation completes, you can run directly:

```bash
openclaw gateway          # Start Gateway server
openclaw chat             # Start CLI chat
openclaw doctor           # Run health check
```

The OpenClaw npm package includes pre-built TypeScript compilation artifacts (`dist/`) and console UI resources (`dist/control-ui/`), requiring no manual compilation by users.

For developers, you can also install from source:

```bash
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm build
pnpm ui:build
node openclaw.mjs gateway
```

## 37.1.2 Daemon Process Management (launchd / systemd)

In production scenarios, Gateway should run as a daemon process to ensure automatic startup after system reboot.

### macOS — launchd

macOS uses `launchd` to manage daemon processes. OpenClaw's macOS application (OpenClaw\.app) includes a built-in Launch Agent manager `GatewayLaunchAgentManager`, which automatically creates a plist file:

```xml
<!-- ~/Library/LaunchAgents/ai.openclaw.gateway.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>ai.openclaw.gateway</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/node</string>
        <string>/usr/local/lib/node_modules/openclaw/openclaw.mjs</string>
        <string>gateway</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>
```

> **Sidebar — launchd**
>
> `launchd` is macOS's process management system, replacing the traditional Unix `init`/`cron`. It defines services through XML-formatted plist configuration files. `RunAtLoad` means the service automatically runs at system startup, and `KeepAlive` means the process automatically restarts if it crashes. Launch Agents (`~/Library/LaunchAgents/`) run under the current user's identity, while Launch Daemons (`/Library/LaunchDaemons/`) run as root.

### Linux — systemd

Linux systems use `systemd` to manage services:

```ini
# /etc/systemd/system/openclaw-gateway.service
[Unit]
Description=OpenClaw Gateway
After=network.target

[Service]
Type=simple
User=openclaw
Environment=NODE_ENV=production
ExecStart=/usr/bin/node /usr/local/lib/node_modules/openclaw/openclaw.mjs gateway
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
```

```bash
sudo systemctl enable openclaw-gateway
sudo systemctl start openclaw-gateway
```

> **Sidebar — systemd**
>
> `systemd` is the initialization system and service manager for modern Linux distributions (Ubuntu, Debian, Fedora, etc.). It defines services using `.service` files, supporting dependency management (`After=`), automatic restart (`Restart=always`), resource limits (`LimitNOFILE=`), and other features. `systemctl enable` sets up automatic startup on boot, and `systemctl start` starts the service immediately.

## 37.1.3 `openclaw doctor` Health Check

`openclaw doctor` is a built-in diagnostic command that checks the completeness of the runtime environment:

```bash
$ openclaw doctor
✔ Node.js v22.11.0 (>= 18 required)
✔ Configuration file exists (~/.openclaw/openclaw.json)
✔ Configuration is valid JSON
✔ API key configured (anthropic)
✔ Gateway port 18789 available
✔ UI assets present (dist/control-ui/)
✔ exec sandbox available
⚠ Tailscale not detected (optional)
```

The `doctor` command is registered in the CLI's maintenance subcommand group:

```typescript
// src/cli/program/register.maintenance.ts
program
  .command("doctor")
  .description("Check environment and repair common issues")
  .option("--fix", "Attempt to fix issues automatically")
  .option("--repair", "Alias for --fix")
  .option("--non-interactive", "Skip prompts")
  .action(async (opts) => {
    await doctorCommand(defaultRuntime, {
      fix: opts.fix || opts.repair,
      nonInteractive: opts.nonInteractive,
    });
  });
```

The items checked by `doctor` include:

| Check Item            | Description                                                 |
| --------------------- | ----------------------------------------------------------- |
| Node.js version       | Minimum 18, recommended 22                                  |
| Configuration file    | Whether `~/.openclaw/openclaw.json` exists and is valid     |
| API keys              | At least one LLM provider is configured                     |
| UI resources          | Whether `dist/control-ui/` exists                           |
| Port availability     | Whether ports 18789 (Gateway) and 18790 (Bridge) are in use |
| exec sandbox          | Whether the sandbox runtime environment is available        |
| Optional dependencies | Tailscale, ffmpeg, etc.                                     |

The `--fix` mode attempts to automatically repair common issues, such as rebuilding UI resources and fixing configuration file formats. The `openclaw update` command also automatically runs `doctor` after updating to ensure environment completeness.

***

## Section Summary

1. **Global npm installation** is the simplest deployment method, includes pre-built artifacts, and requires no compilation.
2. **Daemon process management**: macOS implements automatic startup and process keepalive through launchd plist, while Linux achieves equivalent functionality through systemd service.
3. **`openclaw doctor`** provides comprehensive environment diagnostics with automatic repair mode, making it the first choice tool for troubleshooting deployment issues.
