openclaw-home-pc/workspace/articles/openclaw-install-guide.md
2026-03-21 15:31:06 +08:00

239 lines
5.4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 5 分钟搭建你的专属 AI 助手OpenClaw 超详细安装指南
> 🦐 一只住在你的服务器里,随时待命的数字小龙虾
---
## 先说说 OpenClaw 是啥
想象一下:你有一个 AI 助手,**7×24 小时在线**可以通过微信、Telegram、Discord 随时找到它。它不是云端服务,而是**跑在你自己的服务器上**,数据完全掌控在自己手里。
这就是 **OpenClaw** —— 一个自托管的多通道 AI 网关。
### 它能做什么?
- 📱 **微信消息秒回**:把 WhatsApp/企业微信接入 AI
- 💬 **多平台统一**Telegram、Discord、iMessage 全部打通
- 🤖 **AI 编码助手**:连接 Pi 等 AI Agent帮你写代码、查问题
- 🔒 **数据私有**:所有对话记录都在自己服务器上
- 📸 **媒体支持**:发图片、语音、文件都能处理
### 为什么要自托管?
| 云端 AI 服务 | OpenClaw 自托管 |
|------------|----------------|
| 对话数据存在别人服务器 | 数据完全自己掌控 |
| 每月订阅费用不菲 | 只需付 API 调用费 |
| 功能受限于平台政策 | 想怎么改就怎么改 |
| 断网就歇菜 | 可以本地部署离线能力 |
---
## 开始安装(超简单)
### 系统要求
- ✅ macOS、Linux 或 Windows推荐 WSL2
- ✅ 能上网(需要下载依赖)
- ✅ 一个 AI 服务商的 API Key比如阿里云百炼、OpenAI 等)
**Node.js** 不用管!安装脚本会自动帮你装好 Node 22+。
---
### 方法一:一键安装脚本(强烈推荐⭐)
这是最简单的方式,一条命令搞定所有:
#### macOS / Linux / WSL2
打开终端,复制粘贴:
```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```
然后按提示操作就行,脚本会:
1. 检测并安装 Node.js 22+
2. 安装 OpenClaw
3. 启动配置向导
#### WindowsPowerShell
右键点击 PowerShell选择「以管理员身份运行」
```powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
```
---
### 方法二npm 安装(适合老手)
如果你已经装了 Node 22+,可以直接用 npm
```bash
npm install -g openclaw@latest
openclaw onboard --install-daemon
```
> 💡 遇到 `sharp` 报错?加上这个环境变量:
> ```bash
> SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest
> ```
---
### 方法三Docker 部署(适合服务器)
想用 Docker官方有完整镜像
```bash
docker run -d \
--name openclaw \
-p 18789:18789 \
-v ~/.openclaw:/root/.openclaw \
openclaw/openclaw:latest
```
详细文档https://docs.openclaw.ai/install/docker
---
## 安装后的配置向导
安装完成后,会自动启动 `openclaw onboard` 向导。跟着提示走:
### 1⃣ 选择 AI 服务商
支持的服务商:
- 阿里云百炼(通义千问)
- OpenAIGPT-4
- AnthropicClaude
- 智谱 AI
- Moonshot月之暗面
- 以及其他 OpenAI 兼容接口
**推荐国内用户**:阿里云百炼或 Moonshot速度快、价格低。
### 2⃣ 输入 API Key
去对应的服务商官网申请 API Key粘贴进去。
### 3⃣ 选择聊天通道
想用什么聊天?
- ✅ WhatsApp需要手机号接收验证码
- ✅ Telegram需要 Bot Token
- ✅ Discord需要 Bot Token
- ✅ 企业微信(需要 Webhook
**新手推荐**Telegram 最简单5 分钟搞定。
### 4⃣ 安装后台服务
向导会问你是否安装为系统服务(开机自启),选 **是** 就对了。
---
## 验证安装
打开终端,运行:
```bash
# 检查状态
openclaw status
# 打开网页控制台
openclaw dashboard
# 诊断问题
openclaw doctor
```
如果一切正常,你会看到:
```
✓ Gateway is running
✓ Channels configured
✓ All systems operational
```
---
## 常见问题
### ❓ `openclaw` 命令找不到
这是 PATH 问题,运行:
```bash
export PATH="$(npm prefix -g)/bin:$PATH"
```
然后把这个加到你的 `~/.bashrc``~/.zshrc` 里。
### ❓ 安装时卡住不动
可能是网络问题,试试:
1. 换个网络环境
2. 使用国内镜像源
3. 检查防火墙设置
### ❓ WhatsApp 扫码失败
WhatsApp 需要稳定的国际网络,建议:
1. 使用 Telegram 替代
2. 或者配置好代理后再试
### ❓ 服务启动失败
查看日志:
```bash
openclaw gateway logs
```
常见问题:
- 端口被占用 → 换个端口 `--port 18790`
- 配置文件错误 → `openclaw doctor` 检查
---
## 下一步做什么?
安装完成后,你可以:
1. **打开网页控制台**http://127.0.0.1:18789
2. **配置更多通道**`openclaw channels login`
3. **自定义 AI 行为**:编辑 `~/.openclaw/workspace/SOUL.md`
4. **添加定时任务**:比如每天推送天气、新闻
5. **开发自己的技能**:参考官方文档写插件
---
## 资源链接
- 📚 **官方文档**https://docs.openclaw.ai
- 💬 **Discord 社区**https://discord.com/invite/clawd
- 🐙 **GitHub 源码**https://github.com/openclaw/openclaw
- 🔧 **技能市场**https://clawhub.com
---
## 结语
OpenClaw 最大的魅力在于**完全掌控**
- 你的数据,你做主
- 你的 AI你定制
- 你的服务,你运维
花 5 分钟安装,收获一个 24 小时待命的专属 AI 助手。这笔买卖,值!
> 🦐 **皮皮虾提示**:安装过程中遇到任何问题,欢迎在评论区留言,我会尽力解答~
---
**觉得有用?点赞 + 在看,让更多小伙伴用上私有 AI 助手!** 🚀