在 Ubuntu 22.04 上安装 OpenClaw,官方推荐一键脚本最省心;也可以手动分步安装,适合需要自定义环境的场景。下面给你两种完整方案。
一、一键脚本安装(推荐,最快)
1. 准备环境(可选,更稳)
sudo apt update && sudo apt upgrade -y sudo apt install -y curl git build-essential
2. 执行官方安装脚本
curl -fsSL https://openclaw.ai/install.sh | bash
脚本会自动:
检测并安装 Node.js 22+/24+
全局安装 OpenClaw CLI
启动初始化向导(onboard)
3. 完成初始化(关键)
脚本结束后,按提示完成配置,或手动执行:
openclaw onboard # 如需后台守护进程(推荐长期运行) openclaw onboard --install-daemon初始化时建议:
模型:先选本地 Ollama(路径最短)
Gateway:本地模式
消息通道:可先跳过
技能:装基础包
4. 验证安装
openclaw --version # 查看服务状态(如装了 daemon) systemctl status openclaw
二、手动分步安装(原生、可控)
1. 系统更新与基础依赖
sudo apt update && sudo apt upgrade -y sudo apt install -y curl git build-essential ca-certificates
2. 安装 Node.js 22 LTS(必须 ≥22.16)
# 添加 NodeSource 源 curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - # 安装 Node.js sudo apt install -y nodejs # 验证 node -v # 应输出 v22.x.x npm -v
3. (可选)配置国内 npm 镜像(加速)
npm config set registry https://registry.npmmirror.com # 验证 npm config get registry
4. 全局安装 OpenClaw CLI
sudo npm install -g openclaw@latest # 验证 openclaw --version
5. 初始化与后台服务
# 启动配置向导 openclaw onboard # 安装并启用 systemd 守护进程(后台运行) openclaw onboard --install-daemon
6. 常用管理命令
# 启动服务 sudo systemctl start openclaw # 开机自启 sudo systemctl enable openclaw # 查看日志 journalctl -u openclaw -f # 停止服务 sudo systemctl stop openclaw
三、常见问题与排查
- Node 版本过低卸载旧版,重新安装 Node 22+:
sudo apt remove -y nodejs npm # 再执行上面的 Node 安装步骤
- 权限不足全局安装时加
sudo,或用nvm管理 Node(推荐): # 安装 nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash source ~/.bashrc # 安装 Node 22 nvm install 22 nvm use 22 # 再安装 openclaw(无需 sudo) npm install -g openclaw@latest
- 安装卡住 / 超时切换 npm 镜像,或用 git 源码安装:
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method git
四、启动与使用
安装完成后,直接在终端运行:
openclaw
或通过 Web 界面访问(默认 http://localhost:3210)。









