OpenClaw安装和初始化配置手册
根据 OpenClaw 官方帮助文档整理生成的简易配置手册。
·
OpenClaw 安装和初始化配置手册
一、安装方式
1. 🧴 npm 安装(推荐)
支持平台:macOS、Linux、Windows (WSL2)
# 安装 brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# 查询当前使用的镜像源
npm get registry
# 设置为淘宝镜像源
npm config set registry https://registry.npmmirror.com/
# 还原为官方镜像源
npm config set registry https://registry.npmjs.org/
# 安装 CLI
npm install -g openclaw@latest
# 验证安装
openclaw --version
要求:
- Node.js ≥ 22.12.0
- npm / pnpm / bun 任选其一
2. 🐳 Docker 部署
适合服务器或快速尝鲜:
# 官方镜像
docker run -d \
--name openclaw \
-v ~/.openclaw:/root/.openclaw \
-p 18789:18789 \
openclaw/openclaw:latest
3. 📦 Nix 安装
适合 Nix 用户:
nix run github:openclaw/nix-openclaw
4. 🔨 从源码构建
仅限开发或高级用户:
# 需要 pnpm
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm build
pnpm openclaw onboard --install-daemon
5. 🌐 curl 一键安装
(官方可能有,但当前网络环境下无法验证)
curl -fsSL https://get.openclaw.ai | sh
如果上面不行,可以试试:
# 备用方式
bash -c "$(curl -fsSL https://raw.githubusercontent.com/openclaw/openclaw/main/scripts/install.sh)"
二、初始化配置
方式一:交互式向导(推荐首次使用)
# 启动初始化向导
openclaw onboard
向导会引导你完成:
- 配置模型 API Key(OpenAI/Anthropic/MiniMax 等)
- 设置 Gateway 认证方式
- 配置频道(Telegram/Discord/飞书等)
- 安装技能
- 安装系统服务
常用参数:
# 非交互式安装
openclaw onboard \
--openai-api-key "sk-xxx" \
--install-daemon \
--flow quickstart
# 跳过频道配置
openclaw onboard --skip-channels
# 跳过技能安装
openclaw onboard --skip-skills
# 重置后全新安装
openclaw onboard --reset
方式二:手动配置
# 查看配置
openclaw config file
# 交互式配置
openclaw configure
# 查看完整配置
openclaw config get
三、Gateway 管理
启动 Gateway
# 前台运行
openclaw gateway
# 指定端口
openclaw gateway --port 19000
# 开发模式(隔离配置)
openclaw --dev gateway
安装系统服务
# 安装为系统服务(后台运行)
openclaw onboard --install-daemon
# 或手动
openclaw gateway install
服务控制
openclaw gateway start # 启动
openclaw gateway stop # 停止
openclaw gateway restart # 重启
openclaw gateway status # 状态
四、配置模型
查看可用模型
openclaw models list
设置默认模型
openclaw models set anthropic/claude-sonnet-4-20250514
openclaw models set openai/gpt-4o
openclaw models set minimax/MiniMax-M2.5
添加模型认证
# 添加 API Key
openclaw models auth add
# 或直接设置
openclaw configure --section model
五、配置频道
# 查看支持的频道
openclaw channels --help
# 配置特定频道
openclaw configure --section channels
# 例如配置飞书
openclaw channels login --channel feishu
六、验证安装
# 健康检查
openclaw status
# 诊断问题
openclaw doctor
# 查看日志
openclaw logs --follow
七、常用命令速查
| 功能 | 命令 |
|---|---|
| 启动 | openclaw gateway |
| 状态 | openclaw status |
| 配置 | openclaw configure |
| 更新 | openclaw update |
| 诊断 | openclaw doctor |
| 日志 | openclaw logs --follow |
八、配置文件位置
- 主配置:
~/.openclaw/openclaw.json - 工作空间:
~/.openclaw/workspace/ - 日志:
~/.openclaw/logs/ - 会话:
~/.openclaw/sessions/
九、官方资源
-
官网:https://openclaw.ai
-
文档:https://docs.openclaw.ai
-
GitHub:https://github.com/openclaw/openclaw
-
Discord:https://discord.gg/clawd
更多推荐



所有评论(0)