> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hingnet.com.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 安装与启动

> 安装 OpenClaw CLI 并完成首次配置

<Info>
  本文档精简整理了 OpenClaw 安装与基本使用流程。完整文档请参阅 [OpenClaw 官方文档](https://github.com/openclaw/openclaw)。
</Info>

## 环境要求

| 项目      | 要求                               |
| ------- | -------------------------------- |
| 操作系统    | macOS / Linux / Windows（推荐 WSL2） |
| Node.js | **≥ 22**                         |
| 包管理器    | npm / pnpm / bun                 |

检查 Node.js 版本：

```bash theme={null}
node -v
```

若版本低于 22，推荐通过 nvm 安装：

```bash theme={null}
# 安装 nvm（Linux / macOS）
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc  # 或 ~/.zshrc

# 安装并使用 Node 22
nvm install 22
nvm use 22
```

## 全局安装 CLI

```bash theme={null}
npm install -g openclaw@latest
```

验证安装：

```bash theme={null}
openclaw --version
```

## 首次配置（向导模式）

运行向导并安装守护进程：

```bash theme={null}
openclaw onboard --install-daemon
```

向导会自动完成以下步骤：

* 创建 OpenClaw 工作目录（`~/.openclaw`）
* 引导配置模型提供方（可先跳过，后续接入 HingNet AI 时再配置）
* 配置默认模型与会话参数
* 配置通讯渠道（WhatsApp / Telegram / Slack / 飞书 / WebChat 等）
* 安装并启动 Gateway 守护进程

<Tip>
  如需接入 HingNet AI，建议在向导中先跳过模型配置，直接参考 [接入 HingNet AI](/ecosystem/openclaw-hingnet) 进行配置。
</Tip>

## 手动启动 Gateway（调试用）

```bash theme={null}
openclaw gateway --port 18789 --verbose
```

* 默认控制平面地址：`ws://127.0.0.1:18789`
* `--verbose` 输出详细日志，便于排查问题

## 基本使用

### 终端发送消息

```bash theme={null}
openclaw message send \
  --to +1234567890 \
  --message "Hello from OpenClaw"
```

`--to` 的具体格式取决于你配置的通讯渠道（手机号、聊天 ID、频道等）。

### Agent 对话模式

```bash theme={null}
openclaw agent --message "帮我列一个简单的出差准备清单"
```

通过 Gateway 调用已配置的默认模型，适合快速测试。

### Web UI

Gateway 运行后，浏览器访问日志中打印的地址（通常为 `http://127.0.0.1:18789`），可使用：

* **Dashboard**：查看 Gateway 状态、节点、通道
* **WebChat**：浏览器中直接对话
* **Channels**：管理通讯渠道配置
* **Models**：查看与调整模型参数

## 高级部署

<AccordionGroup>
  <Accordion title="从源码运行（开发场景）">
    ```bash theme={null}
    git clone https://github.com/openclaw/openclaw.git
    cd openclaw
    pnpm install
    pnpm ui:build
    pnpm build
    pnpm openclaw onboard --install-daemon
    pnpm gateway:watch  # 开发模式，代码变更自动重载
    ```
  </Accordion>

  <Accordion title="Docker 部署（服务器场景）">
    ```bash theme={null}
    git clone https://github.com/openclaw/openclaw.git
    cd openclaw

    # 方式一：脚本一键部署
    ./docker-setup.sh

    # 方式二：docker-compose
    docker-compose up -d
    ```

    启动后按 compose 文件中暴露的端口访问 Gateway 与 Web UI。
  </Accordion>
</AccordionGroup>

## 常见问题

<AccordionGroup>
  <Accordion title="CLI 命令找不到（command not found）">
    * 确认 `npm install -g openclaw@latest` 执行成功
    * 检查全局 npm bin 路径已加入 `PATH`
  </Accordion>

  <Accordion title="Node 版本过低">
    使用 nvm 安装 Node 22+ 后重新安装 OpenClaw CLI。
  </Accordion>

  <Accordion title="Gateway 启动报错">
    执行诊断命令：

    ```bash theme={null}
    openclaw doctor
    ```

    按提示检查配置、权限、网络等。
  </Accordion>

  <Accordion title="消息通道无法收发">
    重新运行 `openclaw onboard`，检查各通道的 Token、证书、Webhook 等配置。
  </Accordion>
</AccordionGroup>

## 下一步

<Card title="接入 HingNet AI" icon="plug" href="/ecosystem/openclaw-hingnet">
  配置 HingNet AI 模型提供方，通过 HingNet AI 聚合平台调用 AI 模型。
</Card>
