跳转到内容
最近更新

OpenClaw 本地安装(Mac / Linux)

⚠️ 重要安全提醒
OpenClaw 可能具备较高权限能力,建议先在旧电脑、虚拟机或独立账号上测试。

你将完成什么

  • 在 Mac 或 Linux 安装 OpenClaw
  • 完成 onboarding 并验证第一次成功响应
  • 学会如何启动、更新、重启和卸载 OpenClaw
  • 解决 PATH、代理、权限和旧版本冲突等常见问题

开始前准备

你需要什么

  • macOS 或 Linux 终端
  • 能访问安装脚本的网络环境
  • 一个可用的模型 API Key,例如 Anthropic / Claude

推荐环境

Step 0:快速检查系统

Command
uname -awhoami

Step 1:安装 OpenClaw

方式 A:先下载再执行

Command
curl -fsSL https://openclaw.bot/install.sh -o install.shsed -n '1,120p' install.shbash install.sh

方式 B:最快安装

Command
curl -fsSL https://openclaw.bot/install.sh | bash

验证安装结果

Command
openclaw --version || truewhich openclaw || true

Step 2:处理“命令找不到”

重新打开终端

很多安装脚本会修改 PATH,新开一个 shell 往往就能生效。

重新加载 shell 配置

Command
source ~/.zshrc 2>/dev/null || truesource ~/.bashrc 2>/dev/null || true

检查 PATH 和安装位置

Command
echo $PATHwhich openclaw || true

Step 3:清理旧版本残留

OpenClaw 之前曾使用 Moltbot 与 Clawdbot 名称,旧的全局包可能导致冲突。

Command
npm uninstall -g clawdbot || truenpm uninstall -g moltbot || truenpm uninstall -g openclaw || true

然后重新执行 Step 1。

Step 4:完成 onboarding

Command
openclaw onboard --flow quickstart

推荐做法:

  • 第一个通道优先选 Telegram,验证最简单
  • 密钥优先放在本地配置或 .env,不要写进 git

验证 onboarding

  • 配置写入 ~/.openclaw
  • 提示流程能够正常完成,没有持续报错

Step 5:启动 OpenClaw

前台启动

Command
openclaw start

后台启动

Command
openclaw start --detach

修改配置后的重启

Command
openclaw gateway restart || openclaw restart

验证启动

  • 日志中没有持续错误
  • 配置好的通道里可以收到测试回复

Step 6:如何更新 OpenClaw

如果你是本地安装,可以更新 CLI 或重新执行最新安装流程,然后重启 gateway。

Command
npm i -g openclaw@latestopenclaw --versionopenclaw gateway restart || openclaw restart

如果你运行在 Docker 或 VPS 上,不要套用本地更新方式,改看 Docker / VPS 部署指南

Step 7:如何卸载 OpenClaw

如果你要从本地删除 OpenClaw,先卸载全局包,再决定是否保留本地状态目录。

Command
npm uninstall -g openclaw || truewhich openclaw || true

可选清理:

Command
rm -rf ~/.openclaw

只有在你不再需要配置、历史和本地状态时,才删除 ~/.openclaw

Step 8:代理或受限网络问题

如果 onboarding 卡住、技能下载失败、通道请求超时,优先尝试代理。

Command
export https_proxy=http://127.0.0.1:7890export http_proxy=http://127.0.0.1:7890openclaw start

Step 9:权限错误

如果遇到 EACCES 或 permission denied:

常见问题

通道不响应

  • 重新检查模型 Key
  • 确认网络或代理可用
  • 第一个验证通道优先使用 Telegram

技能或依赖下载失败

  • 确认网络稳定
  • 受限网络下优先走代理
  • 如果问题和技能或插件相关,继续看 高级配置

相关 OpenClaw 指南