OpenClaw 完整安装教程(2026最新版·全平台)
本文适配 OpenClaw v3.22+ 版本,覆盖 macOS、Windows、Linux 三大系统,含一键脚本、npm、源码三种安装方式,附初始化、AO集成与常见问题解决,可直接对照执行。
一、安装前准备(必看)
1.1 系统与硬件要求
- 操作系统:Windows 10+/macOS 12+/Linux(Ubuntu 20.04+、Debian 11+)
- 内存:最低 2GB,推荐 4GB+
- 存储:可用空间 ≥1GB(推荐 10GB+)
- 核心依赖 :Node.js ≥v22.14+(推荐 v24 LTS)
- 可选依赖:Python 3.10+(部分AO技能)、Git(源码安装)
1.2 权限与网络
- Windows:以管理员身份运行 PowerShell
- macOS/Linux:命令前加
sudo获取权限 - 网络:可正常联网;国内用户建议使用镜像加速
二、三种安装方式(任选其一)
方式1:一键脚本安装(新手首选·全自动)
自动检测系统、安装 Node.js、部署 OpenClaw 并启动初始化向导。
macOS / Linux / WSL2
bash
# 官方脚本(推荐)
curl -fsSL https://openclaw.ai/install.sh | bash
# 国内加速镜像(网络不佳时用)
curl -fsSL https://gitee.com/openclaw/install/raw/main/install.sh | bash
Windows(PowerShell·管理员)
powershell
# 官方脚本
iwr -useb https://openclaw.ai/install.ps1 | iex
# 跳过初始化向导(可选)
iwr -useb https://openclaw.ai/install.ps1 | iex -NoOnboard
方式2:npm 全局安装(普通用户·版本可控)
前提:已安装 Node.js ≥v22.14+
bash
# 检查 Node 版本
node --version # 必须 ≥v22.14.0
# 全局安装最新版
npm install -g openclaw@latest
# 国内镜像加速(可选)
npm config set registry https://registry.npmmirror.com
npm install -g openclaw@latest
方式3:源码安装(开发者·自定义编译)
前提:安装 Node.js、pnpm、Git
bash
# 1. 安装 pnpm(推荐)
npm install -g pnpm
# 2. 克隆源码(官方/Gitee)
git clone https://github.com/openclaw/openclaw.git
# 国内镜像
git clone https://gitee.com/openclaw/openclaw.git
# 3. 进入目录、安装依赖、构建
cd openclaw
pnpm config set registry https://registry.npmmirror.com # 国内加速
pnpm install
pnpm run build
# 4. 全局链接
npm link
三、安装验证
bash
# 查看版本(出现版本号即成功)
openclaw --version
# 或
openclaw -v
四、初始化配置(onboard 向导)
安装完成后自动启动,或手动执行:
bash
openclaw onboard
4.1 向导步骤(关键)
- Gateway 网关:设置端口(默认 18789)、启用后台服务
- 工作区 :指定数据目录(默认
~/.openclaw) - LLM 配置:填入 API Key(支持 Claude、GPT、DeepSeek 等)
- 技能安装:启用 Agency Orchestrator(AO)多 Agent 引擎
4.2 启动服务
bash
# 启动网关(后台运行)
openclaw start --daemon
# 查看状态
openclaw status
# 访问 Web UI
浏览器打开:http://localhost:18789
五、集成 Agency Orchestrator(AO)
5.1 安装 AO 扩展
bash
# 进入 OpenClaw 扩展目录
cd ~/.openclaw/extensions
# 安装 AO
git clone https://github.com/openclaw/agent-orchestrator.git
cd agent-orchestrator
npm install
# 注册 AO 到 OpenClaw
openclaw extension enable agent-orchestrator
5.2 启动 AO 服务
bash
# 启动 AO 调度器
npx ao start --daemon
# 检查 AO 状态
npx ao status # 显示 running 即正常
5.3 注册预设 Agent(触发工作流必需)
bash
# 注册内容创作 Agent(对应你之前的 YAML 模板)
npx ao register topic-planner claude-3-5-sonnet "选题规划师" --tools web_search
npx ao register researcher claude-3-5-sonnet "研究员" --tools web_search,read
npx ao register writer claude-3-5-sonnet "撰稿人"
npx ao register reviewer claude-3-5-sonnet "审稿人"
npx ao register formatter claude-3-5-sonnet "排版师"
# 查看已注册 Agent
npx ao agents list
六、在 OpenClaw 聊天框触发 AO 工作流
6.1 自然语言触发(直接发消息)
启动AI技术文创作全流程
或
orchestrate 执行内容创作工作流
6.2 斜杠命令触发(精准执行)
bash
# 直接运行你的 YAML 模板
/ao run ~/.openclaw/workspaces/ao-content/ai-article-writing.yaml
6.3 实时查看进度
OpenClaw 聊天框会输出:
[AO] 已启动:AI技术文创作全流程
[AO] Step1/5:topic-planner 正在选题...
[AO] Step5/5:完成!成品:final-article.md
七、常见问题解决
7.1 Node 版本过低
bash
# macOS/Linux 安装 Node 24
curl -fsSL https://nodejs.org/dist/v24.0.0/node-v24.0.0-linux-x64.tar.xz | tar -xJf - -C /usr/local --strip-components=1
# Windows 下载:https://nodejs.org/
7.2 权限不足
bash
# macOS/Linux
sudo curl -fsSL https://openclaw.ai/install.sh | bash
# Windows:右键 PowerShell → 以管理员身份运行
7.3 AO 触发失败
bash
# 重启 AO
npx ao stop
npx ao start --daemon
# 重新注册缺失 Agent
npx ao register [Agent名] [模型] "描述" --tools [工具]
7.4 国内网络超时
bash
# 替换为国内镜像
npm config set registry https://registry.npmmirror.com
git clone https://gitee.com/openclaw/agent-orchestrator.git
八、卸载 OpenClaw
bash
# 停止服务
openclaw stop
npx ao stop
# 卸载 npm 版本
npm uninstall -g openclaw
# 删除数据目录
rm -rf ~/.openclaw
九、注意事项
- 安装前务必关闭杀毒/防火墙,避免拦截脚本与端口
- AO 工作流需确保所有 Agent 已注册、模型 API Key 有效
- 定期执行
openclaw update与npx ao update保持版本最新 - 日志路径:
~/.openclaw/logs/,报错时优先查看日志定位问题