
OpenClaw 在 Linux 中的创建与部署指南
📖 什么是 OpenClaw?
OpenClaw 是⼀个强⼤的 AI 智能体框架,⽀持多模态交互、技能扩展和跨平台部署。它允许⽤
⼾通过⾃然语⾔控制各种⼯具和服务,实现⾃动化⼯作流。
🐧 Linux 系统要求
⽀持的发⾏版
Ubuntu 20.04+ / 22.04+
Debian 11+
CentOS 8+ / Rocky Linux 8+
Fedora 35+
硬件要求
CPU: 2 核⼼以上
内存:4GB RAM (推荐 8GB)
磁盘:10GB 可⽤空间
⽹络:稳定的互联⽹连接
📦 前置依赖安装
1. 安装 Node.js (v18+)
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# CentOS/RHEL
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo yum install -y nodejs2. 安装 Python (3.10+)
3. 安装 Git
4. 安装 Docker (可选,推荐⽤于快速部署)
# 验证安装
node --version
npm --version
# Ubuntu/Debian
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
# CentOS/RHEL
sudo yum install -y python3 python3-pip python3-devel
# 验证安装
python3 --version
pip3 --version
sudo apt install -y git
# Ubuntu/Debian
sudo yum install -y git
# CentOS/RHEL
git --version
# 添加 Docker 官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -
o /usr/share/keyrings/docker-archive-keyring.gpg
# 添加 Docker 仓库
echo "deb [arch=$(dpkg --print-architecture) signed
by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee
/etc/apt/sources.list.d/docker.list > /dev/null
# 安装 Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
# 启动并设置开机自启
sudo systemctl start dockersudo systemctl enable docker
# 将当前用户加入 docker 组
sudo usermod -aG docker $USER
newgrp docker
# 验证安装
docker --version
docker run hello-world
🚀 安装步骤
⽅案 A:源码安装(推荐⽤于开发)
1. 克隆仓库
cd ~
git clone https://github.com/openclaw/openclaw.git
cd openclaw
2. 安装依赖
# 安装 Node.js 依赖
npm install
# 安装 Python 依赖(如果需要)
pip3 install -r requirements.txt
3. 配置环境变量
# 创建环境变量文件
cp .env.example .env
nano .env
# 编辑以下内容(根据你的需求)
OPENCLAW_API_KEY=your_api_key_here
OPENCLAW_WORKSPACE=~/.openclaw/workspace
OPENCLAW_LOG_LEVEL=info
4. 初始化⼯作区# 创建工作区目录
mkdir -p ~/.openclaw/workspace
cd ~/.openclaw/workspace
# 初始化基础文件
openclaw init
5. 启动服务
# 开发模式
npm run dev
# 生产模式
npm start
# 或使用 systemd 服务(推荐)
sudo cp scripts/openclaw.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
# 查看状态
sudo systemctl status openclaw
⽅案 B:Docker 部署(快速上⼿)
1. 拉取镜像
docker pull openclaw/openclaw:latest
2. 创建数据⽬录
mkdir -p ~/.openclaw/workspace
mkdir -p ~/.openclaw/config
3. 启动容器
docker run -d \
--name openclaw \
-p 18789:18789 \
-v ~/.openclaw/workspace:/app/workspace \
-v ~/.openclaw/config:/app/config \-e OPENCLAW_API_KEY=your_api_key_here \
openclaw/openclaw:latest
4. 验证部署
docker ps
curl http://localhost:18789/health
⚙️ 配置⽂件说明
1. openclaw.json - 主配置⽂件
{
"workspace": "~/.openclaw/workspace",
"model": "custom-integrate-api-nvidia-com/qwen/qwen3.5-122b-a10b",
"api_keys": {
"tavily": "tvly-dev-xxxxx",
"nvidia": "nvapi-xxxxx"
},
"plugins": {
"memory": "memory-lancedb-pro",
"browser": "agent-browser"
}
}
2. TOOLS.md - 本地⼯具配置
存储特定于环境的配置(如 API 密钥、设备名称等)
不会被共享或泄露
3. AGENTS.md - 智能体⾏为规则
定义智能体的⾏为准则
安全限制和⼯作流规范
4. SOUL.md - 智能体⼈格设定
定义智能体的性格、语⽓和价值观
个性化交互体验🔧 常⻅问题排查
1. 端⼝冲突
# 检查 18789 端口是否被占用
sudo lsof -i :18789
# 停止占用进程
sudo kill -9 <PID>
# 或修改配置文件中的端口
2. 权限问题
# 确保工作区目录有写权限
chmod -R 755 ~/.openclaw/workspace
chown -R $USER:$USER ~/.openclaw/workspace
3. ⽹络连接问题
# 测试网络连接
curl -I https://api.openclaw.ai
# 检查防火墙
sudo ufw status
sudo ufw allow 18789/tcp
4. Docker 权限问题
# 将用户加入 docker 组
sudo usermod -aG docker $USER
newgrp docker
# 重启 Docker 服务
sudo systemctl restart docker
🔒 安全最佳实践
1. 不要将 API 密钥提交到 Git使⽤ .env ⽂件存储敏感信息
将 .env 添加到 .gitignore
2. 定期更新依赖
npm update
pip3 install --upgrade -r requirements.txt
3. 使⽤最⼩权限原则
不要以 root ⾝份运⾏ OpenClaw
限制⽂件访问权限
4. 启⽤⽇志监控
journalctl -u openclaw -f
5. 定期备份⼯作区
tar -czf openclaw_backup_$(date +%Y%m%d).tar.gz ~/.openclaw/workspace
📚 下⼀步
1. 安装技能: npx skills add <skill-name>
2. 配置记忆系统: memory-lancedb-pro
3. 连接外部服务: api-gateway
4. 创建⾃定义技能:参考 skill-creator ⽂档
📞 ⽀持与反馈
GitHub Issues: https://github.com/openclaw/openclaw/issues
Discord 社区: https://discord.com/invite/clawd
官⽅⽂档: https://docs.openclaw.ai
最后更新:2026-03-23