OpenClaw 安装技巧完全指南
## 一、安装步骤### 1. 环境准备OpenClaw 需要 Node.js 环境推荐版本- **Node.js 24** (推荐)- **Node.js 22 LTS** (22.16 兼容)检查Node版本bashnode --version### 2. 安装OpenClawbashnpm install -g openclawlatest### 3. 初始化配置bashopenclaw onboard --install-daemon这会- 创建配置目录 ~/.openclaw/- 安装Gateway服务- 生成默认配置文件### 4. 启动Gatewaybashopenclaw gateway start### 5. 验证安装打开控制面板bashopenclaw dashboard默认地址http://127.0.0.1:18789/---## 二、常见问题### Q1: npm安装失败**原因**网络问题或权限不足**解决方案**bash# 使用国内镜像npm config set registry https://registry.npmmirror.com# 或使用cnpmnpm install -g cnpm --registryhttps://registry.npmmirror.comcnpm install -g openclawlatest# Windows可能需要管理员权限# 以管理员身份运行PowerShell### Q2: Gateway启动失败**排查步骤**bash# 检查端口占用netstat -ano | findstr :18789# 检查Gateway状态openclaw gateway status# 查看日志openclaw logs# 重启Gatewayopenclaw gateway restart### Q3: 连接渠道配置问题**Telegram配置最简单**1. 找 BotFather 创建机器人2. 获取API Token3. 配置到 ~/.openclaw/openclaw.json**WhatsApp配置**需要扫码授权按提示操作即可。### Q4: 模型API配置在配置文件中添加json{providers: {openai: {apiKey: sk-xxx}}}或使用环境变量bashexport OPENAI_API_KEYsk-xxx### Q5: Windows权限问题powershell# 允许脚本执行Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser# 检查防火墙是否阻止# 添加OpenClaw到允许列表---## 三、配置技巧### 1. 多渠道配置json5{channels: {telegram: {enabled: true,token: YOUR_BOT_TOKEN,// 限制发送者allowFrom: [123456789],},whatsapp: {enabled: true,},discord: {enabled: true,token: YOUR_DISCORD_TOKEN,},},}### 2. 安全配置json5{gateway: {auth: {token: your-secure-token,},},channels: {telegram: {// 群组需要提及才响应groups: {*: { requireMention: true },},},},}### 3. 模型选择json5{agents: {defaults: {model: gpt-4o,// 或使用其他模型// model: claude-3-5-sonnet,},},}### 4. 浏览器自动化配置json5{browser: {enabled: true,defaultProfile: openclaw,// 使用Brave浏览器executablePath: C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe,},}### 5. 远程访问配置使用Tailscale实现安全远程访问json5{gateway: {bind: 0.0.0.0,remote: {tailnet: true,},},}### 6. 日志级别调整json5{logging: {level: info, // debug, info, warn, errorfile: true,},}### 7. 性能优化json5{gateway: {// 增加并发限制maxConnections: 100,// 超时设置timeout: 30000,},}---## 四、进阶技巧### 自定义技能在 ~/.openclaw/workspace/skills/ 创建技能markdown!-- skills/my-skill/SKILL.md -----name: my_skilldescription: 我的自定义技能---# 技能说明...### 定时任务bash# 添加cron任务openclaw cron add --schedule 0 9 * * * --message 早安提醒### 多Agent路由json5{routing: {// 按发送者路由到不同sessionsessions: {user-123: personal-assistant,user-456: work-assistant,},},}---## 五、故障排除清单| 问题 | 命令 ||------|------|| 检查状态 | openclaw status || 检查Gateway | openclaw gateway status || 查看日志 | openclaw logs --tail 100 || 诊断问题 | openclaw doctor || 重置配置 | openclaw reset || 更新版本 | npm update -g openclawlatest |---## 总结OpenClaw安装核心要点1. ✅ 确保Node.js 22环境2. ✅ 使用npm全局安装3. ✅ 运行onboard初始化4. ✅ 配置至少一个消息渠道5. ✅ 设置API密钥遇到问题优先使用bashopenclaw doctoropenclaw logs祝使用愉快