Ubuntu 部署 OpenClaw 安装指南
适用于 Ubuntu 20.04+ / Debian 系统

一、一键安装(推荐)
bash

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

二、手动安装

  1. 安装依赖
    bash

sudo apt update

sudo apt install -y git curl jq ca-certificates openssl

  1. 安装 Node.js 22+
    OpenClaw 需要 Node.js 22+ 版本。
    方式一:nodesource
    bash

安装 Node.js 22

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

sudo apt install -y nodejs

方式二:nvm(推荐)
bash

安装 nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

source ~/.bashrc

安装 Node.js 22

nvm install 22

nvm use 22

验证

node -v

  1. 安装 pnpm
    bash

方式一:npm 全局安装

sudo npm install -g pnpm

方式二:解决权限问题

mkdir -p ~/.npm-global

npm config set prefix ‘~/.npm-global’

echo ‘export PATH=~/.npm-global/bin:$PATH’ >> ~/.bashrc

source ~/.bashrc

npm install -g pnpm

  1. 克隆并构建 OpenClaw
    bash

git clone https://github.com/openclaw/openclaw.git

cd openclaw

pnpm install

pnpm build

初始化
bash

openclaw onboard

按提示选择:
●QuickStart - 快速配置
●填写 API Key
●配置飞书/钉钉等渠道

三、开机自启
bash

允许用户服务开机自启

sudo loginctl enable-linger “$(whoami)”

安装 gateway 服务

openclaw gateway install

四、常见问题
问题 1:Node.js 版本过低
错误:

WARN Unsupported engine: wanted: {“node”:“>=22.12.0”} (current: {“node”:“v20.20.1”})

解决:
bash

卸载旧版本

sudo apt remove --purge -y nodejs npm

sudo apt autoremove -y

重新安装 Node 22

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

sudo apt install -y nodejs

问题 2:dpkg 冲突
错误:

trying to overwrite ‘/usr/include/node/common.gypi’, which is also in package libnode-dev

解决:
bash

清理残留

sudo apt remove --purge -y nodejs npm

sudo rm -rf /usr/include/node

sudo rm -rf /usr/lib/node_modules

sudo apt autoremove -y

重新安装

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

sudo apt install -y nodejs

问题 3:npm 权限拒绝
错误:

Error: EACCES: permission denied, mkdir ‘/usr/lib/node_modules/pnpm’

解决:
bash

方案一:加 sudo

sudo npm install -g pnpm

方案二:配置 npm 路径

mkdir -p ~/.npm-global

npm config set prefix ‘~/.npm-global’

echo ‘export PATH=~/.npm-global/bin:$PATH’ >> ~/.bashrc

source ~/.bashrc

npm install -g pnpm

问题 4:pnpm command not found
解决:
bash

source ~/.bashrc

source ~/.profile

问题 5:飞书配对失败
错误:

OpenClaw: access not configured

解决:
1.检查飞书应用权限是否完整
2.在 OpenClaw 配置中确保 dmPolicy: “pairing”
3.运行 openclaw doctor --fix 修复配置

五、验证安装
bash

查看状态

openclaw status

查看版本

openclaw --version

查看日志

openclaw logs --follow

六、配置飞书

  1. 创建飞书应用
    登录 https://open.feishu.cn/app → 创建企业应用
  2. 配置权限
    批量导入以下权限:
    json

{

“scopes”: {

"tenant": [

  "im:message",

  "im:message:send_as_bot",

  "im:message:readonly",

  "im:message.p2p_msg:readonly",

  "im:resource",

  "im:chat.members:bot_access",

  "contact:user.employee_id:readonly"

]

}

}

  1. 配置 OpenClaw
    bash

openclaw configure

选择飞书渠道,填写 App ID 和 App Secret。
4. 批准配对
bash

查看配对请求

openclaw pairing list feishu

批准配对

openclaw pairing approve feishu

七、常用命令
命令 说明
openclaw status 查看状态
openclaw configure 配置
openclaw gateway restart 重启网关
openclaw logs --follow 查看日志
openclaw pairing list feishu 查看飞书配对请求
openclaw doctor 诊断问题

八、相关链接
●官方文档:https://docs.openclaw.ai/
●安装脚本:https://openclaw.ai/install.sh
●GitHub:https://github.com/openclaw/openclaw
file_path
/workspace/OpenClaw-Ubuntu-安装指南.md

更多推荐