Linux
Linux 是 OpenClaw 的 Tier 1(一级支持)平台,也是服务器部署最常见的选择。支持主流发行版和 ARM 架构。
系统要求
| 项目 | 要求 |
|---|---|
| 架构 | x86_64 或 ARM64 (aarch64) |
| 内存 | 2 GB+(推荐 4 GB+) |
| 磁盘 | 10 GB 可用空间 |
| Node.js | 20.0+ 或使用 Docker |
支持的发行版
| 发行版 | 最低版本 | 包管理器 |
|---|---|---|
| Ubuntu | 22.04 LTS | apt |
| Debian | 12 (Bookworm) | apt |
| Fedora | 38 | dnf |
| Arch Linux | Rolling | pacman |
| RHEL / CentOS Stream | 9 | dnf |
| openSUSE | Tumbleweed | zypper |
安装方式
快速安装脚本
bash
curl -fsSL https://openclaw.ai/install.sh | bash安装脚本安全
建议先查看脚本内容再执行:
bash
curl -fsSL https://openclaw.ai/install.sh -o install.sh
less install.sh
bash install.sh各发行版包管理器安装
bash
# 添加 GPG 密钥和源
curl -fsSL https://repo.openclaw.ai/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/openclaw.gpg
echo "deb [signed-by=/usr/share/keyrings/openclaw.gpg] https://repo.openclaw.ai/apt stable main" | \
sudo tee /etc/apt/sources.list.d/openclaw.list
# 安装
sudo apt update
sudo apt install openclawbash
# 添加仓库
sudo dnf config-manager --add-repo https://repo.openclaw.ai/rpm/openclaw.repo
# 安装
sudo dnf install openclawbash
# AUR 安装
yay -S openclaw
# 或手动
git clone https://aur.archlinux.org/openclaw.git
cd openclaw
makepkg -siDocker 安装
bash
docker run -d \
--name openclaw \
--restart unless-stopped \
-p 7681:7681 \
-v openclaw-data:/app/data \
openclaw/openclaw:latestNode.js 手动安装
bash
# 安装 Node.js 20+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# 安装 OpenClaw
npm install -g openclaw
# 启动
openclaw gateway startsystemd 服务配置
将 OpenClaw 设置为 systemd Service(系统服务),实现开机自启和进程守护。
自动安装服务
bash
openclaw daemon install
openclaw daemon start手动创建服务
ini
[Unit]
Description=OpenClaw AI Gateway
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=openclaw
Group=openclaw
WorkingDirectory=/opt/openclaw
ExecStart=/usr/bin/openclaw gateway start
Restart=always
RestartSec=5
Environment=NODE_ENV=production
# 安全加固
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/openclaw/data
[Install]
WantedBy=multi-user.targetbash
# 创建专用用户
sudo useradd -r -s /bin/false openclaw
# 启用并启动服务
sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
# 查看状态
sudo systemctl status openclaw
# 查看日志
sudo journalctl -u openclaw -fHeadless 服务器部署
在无图形界面的服务器上部署:
bash
# 安装
curl -fsSL https://openclaw.ai/install.sh | bash
# 配置(编辑配置文件)
openclaw configure
# 以后台服务方式运行
openclaw daemon install
openclaw daemon start远程访问
服务器部署后,你可以通过以下方式访问:
- Web 控制台:
http://服务器IP:7681 - CLI 远程连接:
openclaw gateway connect --remote wss://服务器IP:7681 - 手机 App 配对连接
防火墙配置
bash
# UFW (Ubuntu)
sudo ufw allow 7681/tcp
# firewalld (Fedora/RHEL)
sudo firewall-cmd --permanent --add-port=7681/tcp
sudo firewall-cmd --reload
# iptables
sudo iptables -A INPUT -p tcp --dport 7681 -j ACCEPTARM 支持(Raspberry Pi 等)
OpenClaw 原生支持 ARM64 架构:
bash
# 检查架构
uname -m
# 应输出 aarch64
# 安装方式与 x86_64 完全相同
curl -fsSL https://openclaw.ai/install.sh | bashARM32 不支持
OpenClaw 仅支持 64 位 ARM(aarch64/ARM64)。旧版 32 位 ARM 设备(armhf/armv7l)不受支持。请确保运行 64 位操作系统。
Docker on Linux
Linux 是运行 Docker 的最佳平台:
bash
# 安装 Docker
curl -fsSL https://get.docker.com | bash
# Docker Compose 部署
mkdir -p /opt/openclaw && cd /opt/openclawyaml
version: "3.8"
services:
openclaw:
image: openclaw/openclaw:latest
container_name: openclaw
restart: unless-stopped
ports:
- "7681:7681"
volumes:
- ./data:/app/data
- ./config.yaml:/app/config.yaml
environment:
- NODE_ENV=production
- TZ=Asia/Shanghaibash
docker compose up -d故障排查
| 问题 | 解决方案 |
|---|---|
| 端口被占用 | lsof -i :7681 查看并关闭占用进程 |
| 权限不足 | 检查文件所有权:chown -R openclaw:openclaw /opt/openclaw |
| 服务启动失败 | journalctl -u openclaw -e 查看错误日志 |
| Node.js 版本低 | 升级到 20+:nvm install 20 |
| DNS 解析失败 | 检查 /etc/resolv.conf 配置 |
| 音频设备不可用 | 安装 ALSA:sudo apt install alsa-utils |
