Ubuntu 部署 OpenClaw 完整指南
环境信息
- 系统: Ubuntu 22.04 LTS
- 配置: 4 核 8GB 内存,100M 带宽
- 类型: CPU
一、安装依赖
1.1 更新系统包索引
sudo apt update
1.2 安装 curl
sudo apt install -y curl
1.3 通过 NodeSource 安装最新稳定 LTS 版本
添加 NodeSource 仓库并安装 curl:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
验证版本:
node -v
npm -v
实际输出示例:
v24.14.0
11.9.0
1.4 设置淘宝镜像(最常用)
npm config set registry https://registry.npmmirror.com
npm config get registry
验证输出应显示 https://registry.npmmirror.com。
二、安装 OpenClaw
执行官方安装脚本。注意:安装过程中遇到提示时建议勾选 yes。
curl -fsSL https://openclaw.ai/install.sh | bash
安装完成后会看到类似以下的日志,其中包含安全警告和初始化步骤,这是正常现象。
关键信息:OpenClaw installed successfully (2026.2.26)!
同时会提示 PATH 问题,稍后处理。
三、解决 PATH 问题
如果执行 which openclaw 找不到命令,说明 npm 全局 bin 目录未加入环境变量。
检查当前 shell:
echo $SHELL
如果是 /bin/bash,编辑 ~/.bashrc;如果是 /bin/zsh,编辑 ~/.zshrc。
将 npm 全局 bin 目录添加到 PATH:
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc


