OpenClaw 安装教程 - 打造你的个人 AI 助手

OpenClaw 是一个开源的个人 AI 助手,可以在你自己的设备上运行,支持多平台消息接入(WhatsApp、Telegram、Discord、飞书等),让你随时随地与 AI 对话。


📋 目录

  1. 环境要求
  2. 安装 Node.js
  3. 安装 OpenClaw
  4. 运行配置向导
  5. 启动 Gateway
  6. 连接消息平台
  7. 开始使用
  8. 常见问题

1. 环境要求

在安装 OpenClaw 之前,请确保你的系统满足以下要求:

操作系统 要求
Windows 推荐 WSL2(Windows Subsystem for Linux)
macOS 原生支持
Linux 原生支持

运行时要求: Node.js ≥ 22


2. 安装 Node.js

Windows 用户

方法一:使用 WSL2(推荐)

  1. 打开 PowerShell(管理员),运行:
wsl --install
  1. 重启电脑后,WSL2 会自动安装 Ubuntu

  2. 进入 WSL2:

wsl
  1. 安装 Node.js 22:
# 使用 nvm 安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 22
nvm use 22

方法二:直接在 Windows 安装

  1. 下载 Node.js 官网 的 LTS 版本
  2. 运行安装程序,一路 Next 即可
  3. 打开 PowerShell 验证:
node --version  # 应显示 v22.x.x

macOS 用户

# 使用 Homebrew 安装
brew install node@22

# 或使用 nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.zshrc
nvm install 22
nvm use 22

Linux 用户

# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

# 或使用 nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 22
nvm use 22

3. 安装 OpenClaw

安装好 Node.js 后,使用 npm 全局安装 OpenClaw:

npm install -g openclaw@latest

可选: 如果使用 pnpm 或 bun:

# pnpm
pnpm add -g openclaw@latest

# bun
bun add -g openclaw@latest

验证安装:

openclaw --version

4. 运行配置向导

OpenClaw 提供了交互式的配置向导,帮助你完成初始化设置:

openclaw onboard --install-daemon

向导会引导你完成以下步骤:

  1. 选择 AI 模型提供商

    • OpenAI(推荐,支持 ChatGPT)
    • Anthropic(Claude)
    • Google(Gemini)
    • 其他兼容 OpenAI API 的提供商
  2. 配置 API 密钥

    • 输入你的 API Key
    • 或使用 OAuth 登录(支持 OpenAI)
  3. 创建工作空间

    • 设置工作目录
    • 配置代理(可选)
  4. 安装 Gateway 守护进程

    • --install-daemon 参数会自动配置系统服务
    • macOS:使用 launchd
    • Linux:使用 systemd
    • Windows:需要手动配置

5. 启动 Gateway

Gateway 是 OpenClaw 的核心控制平面,负责处理所有消息和请求。

手动启动

openclaw gateway --port 18789 --verbose

作为系统服务运行

配置向导已经安装了守护进程,Gateway 会自动启动。

管理服务:

# 查看状态
openclaw gateway status

# 启动服务
openclaw gateway start

# 停止服务
openclaw gateway stop

# 重启服务
openclaw gateway restart

6. 连接消息平台

OpenClaw 支持多种消息平台,你可以通过配置文件或 CLI 连接。

支持的平台

  • WhatsApp
  • Telegram
  • Discord
  • Slack
  • 飞书(Feishu)
  • Signal
  • Microsoft Teams
  • Matrix
  • LINE
  • 更多…

连接 Telegram

  1. 创建 Telegram Bot:

    • 在 Telegram 中搜索 @BotFather
    • 发送 /newbot 创建新机器人
    • 保存 Bot Token
  2. 配置 OpenClaw:

openclaw config set channels.telegram.botToken "your-bot-token"

连接 Discord

  1. 创建 Discord Bot:

  2. 邀请 Bot 加入服务器:

https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=8
  1. 配置 OpenClaw:
openclaw config set channels.discord.token "your-bot-token"

连接飞书

  1. 创建飞书应用:

  2. 配置权限和事件订阅

  3. 配置 OpenClaw:

openclaw config set channels.feishu.appId "your-app-id"
openclaw config set channels.feishu.appSecret "your-app-secret"

7. 开始使用

通过 CLI 对话

# 直接与 AI 对话
openclaw agent --message "帮我写一个 Python 脚本"

# 启用深度思考模式
openclaw agent --message "分析这段代码的优化空间" --thinking high

发送消息

# 发送消息到指定渠道
openclaw message send --to +1234567890 --message "Hello from OpenClaw"

访问 WebChat

Gateway 启动后,可以通过浏览器访问:

http://localhost:18789

使用 macOS/Windows 应用

  • macOS:下载菜单栏应用,支持语音唤醒、Canvas 等
  • iOS/Android:使用节点应用,支持移动端控制

8. 常见问题

Q: 如何更新 OpenClaw?

npm update -g openclaw@latest
openclaw doctor  # 检查配置

Q: 如何查看日志?

openclaw logs

Q: Gateway 启动失败怎么办?

  1. 检查端口是否被占用:
# Linux/macOS
lsof -i :18789

# Windows
netstat -ano | findstr :18789
  1. 运行诊断:
openclaw doctor

Q: 如何配置代理?

openclaw config set proxy "http://127.0.0.1:7890"

Q: 安全性如何?

  • 默认启用 DM 配对机制,陌生人需先配对才能对话
  • 使用 openclaw doctor 检查安全配置
  • 所有数据本地存储,不上传云端

📚 更多资源

  • 官方文档:https://docs.openclaw.ai
  • GitHub:https://github.com/openclaw/openclaw
  • Discord 社区:https://discord.gg/clawd
  • 技能商店:https://clawhub.com

总结

OpenClaw 是一个功能强大的个人 AI 助手平台,支持:

✅ 多平台消息接入(WhatsApp、Telegram、Discord、飞书等)
✅ 多种 AI 模型(OpenAI、Claude、Gemini 等)
✅ 本地运行,数据隐私安全
✅ 可扩展技能系统
✅ 语音交互支持
✅ 跨平台支持(Windows、macOS、Linux、iOS、Android)

开始使用 OpenClaw,让 AI 成为你的私人助手!


如果这篇文章对你有帮助,欢迎点赞收藏关注 ~ 🙏

Logo

小龙虾开发者社区是 CSDN 旗下专注 OpenClaw 生态的官方阵地,聚焦技能开发、插件实践与部署教程,为开发者提供可直接落地的方案、工具与交流平台,助力高效构建与落地 AI 应用

更多推荐