OpenClaw(龙虾 AI)教程覆盖 Windows/macOS/Linux,含一键脚本、手动安装、Docker 部署,附常见报错速解,新手也能一次成功。
OpenClaw 火到爆,90% 人装不上!2026年3 月 21 日 20:00|叶梓老师免费直播零基础保姆级安装,命令行 / 环境坑一次全解。

一、安装前必备检查(必做!)
- 系统要求
- Windows:Win10 2004+/Win11,必须开启 WSL2(官方推荐)
- macOS:12+,Intel/Apple Silicon 均可
- Linux:Ubuntu 20.04+/Debian/Fedora 等主流发行版
- 内存≥8GB(推荐 16GB),硬盘≥10GB 可用空间
- 环境依赖
- Node.js ≥ 22(一键脚本会自动安装,手动需提前配置)
- 网络稳定,国内用户建议提前切换 npm 镜像
- 权限准备
- Windows:全程管理员身份运行 PowerShell/WSL
- macOS/Linux:终端需 sudo 权限
二、Windows 安装(两种方案)
方案 A:WSL2 + Ubuntu(官方推荐・稳定)
步骤 1:安装 WSL2(管理员 PowerShell)
powershell
# 安装WSL2与Ubuntu 22.04
wsl --install -d Ubuntu-22.04
# 设置WSL2为默认版本
wsl --set-default-version 2
安装完成后重启电脑,启动 Ubuntu 并设置用户名、密码。
步骤 2:WSL 内安装 OpenClaw(Ubuntu 终端)
bash
运行
# 更新系统
sudo apt update && sudo apt upgrade -y
# 官方一键脚本(自动装Node.js 22)
curl -fsSL https://openclaw.ai/install.sh | bash
# 国内加速脚本(推荐)
# curl -fssl https://open-claw.org.cn/install-cn.sh | bash
步骤 3:初始化与启动
bash
运行
# 初始化配置(选择模型、输入API Key)
openclaw onboard --install-daemon
# 启动网关
openclaw gateway start
# 打开Web控制台(http://localhost:18789)
openclaw dashboard
方案 B:原生 PowerShell(快速体验・不推荐长期)
步骤 1:开启脚本权限(管理员 PowerShell)
powershell
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# 提示时输入Y确认
步骤 2:一键安装
powershell
# 官方脚本
iwr -useb https://openclaw.ai/install.ps1 | iex
# 国内加速脚本
# iwr -useb https://open-claw.org.cn/install-cn.ps1 | iex
步骤 3:验证与启动
powershell
# 验证版本
openclaw --version
# 初始化
openclaw onboard
# 启动网关
openclaw gateway start
三、macOS 安装(一键脚本・最简单)
步骤 1:打开终端(Command + 空格→输入 Terminal)
步骤 2:执行一键脚本
bash
运行
# 官方脚本(输入开机密码)
curl -fsSL https://openclaw.ai/install.sh | bash
# 国内加速
# curl -fssl https://open-claw.org.cn/install-cn.sh | bash
步骤 3:初始化与启动
bash
运行
openclaw onboard --install-daemon
openclaw gateway start
openclaw dashboard
四、Linux 安装(Ubuntu/Debian 为例)
步骤 1:更新系统与依赖
bash
运行
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git
步骤 2:一键安装 OpenClaw
bash
运行
# 官方脚本
curl -fsSL https://openclaw.ai/install.sh | bash
# 国内加速
# curl -fssl https://open-claw.org.cn/install-cn.sh | bash
步骤 3:初始化与启动
bash
运行
openclaw onboard --install-daemon
openclaw gateway start
openclaw dashboard
五、Docker 部署(环境隔离・技术用户首选)
步骤 1:安装 Docker(已安装可跳过)
bash
运行
# Ubuntu/Debian
sudo apt install -y docker.io docker-compose
sudo systemctl start docker
sudo systemctl enable docker
步骤 2:拉取镜像并启动
bash
运行
# 拉取最新镜像
docker pull openclaw/openclaw:latest
# 启动容器(端口18789,数据持久化)
docker run -d --name openclaw \
-p 18789:18789 \
-v ~/.openclaw:/root/.openclaw \
--restart unless-stopped \
openclaw/openclaw:latest
步骤 3:访问控制台
浏览器打开:http://localhost:18789
六、常见报错速解(90% 问题都在这)
- Node.js 版本过低
- 报错:
node: command not found或版本 < 22 - 解决:一键脚本会自动安装;手动安装:
nvm install 22 && nvm use 22
- 报错:
- 权限不足(EACCES)
- Windows:用管理员PowerShell/WSL
- macOS/Linux:命令前加
sudo
- 命令找不到(command not found)
- 解决:安装后重启终端 ,或手动添加 PATH:
export PATH=$PATH:~/.openclaw/bin
- 解决:安装后重启终端 ,或手动添加 PATH:
- 依赖下载失败 / 卡住
- 解决:切换 npm 镜像:
npm config set registry https://registry.npmmirror.com
- 解决:切换 npm 镜像:
- 端口占用(18789)
- 解决:
openclaw gateway start --port 自定义端口(如 18790)
- 解决:
- WSL2 安装失败
- 解决:BIOS 开启虚拟化(VT-x/AMD-V),重启电脑后重试
七、安装成功验证
- 终端输入:
openclaw --version,显示版本号(如 v2026.3.15)即成功 - 浏览器访问:
http://localhost:18789,打开 OpenClaw 控制台 - 输入模型 API Key(如 OpenAI、阿里云百炼),即可开始使用