OpenClaw一键安装脚本,适合CentOS/Ubuntu/Debian

📅 2026/7/1 17:32:36
OpenClaw一键安装脚本,适合CentOS/Ubuntu/Debian
如果你有一台Linux服务器不管是什么发行版这篇脚本可以直接用。一行命令安装全自动处理依赖、配置和启动。我自己在CentOS 7、Ubuntu 22.04和Debian 12上都测试过全部通过。OpenClaw最新版本一键部署包下载地址TopClaw官网一键免费部署OpenClaw一键安装脚本复制以下内容保存为install_openclaw.sh#!/bin/bash set -e echo OpenClaw 一键安装脚本 # 检测发行版 if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then echo 检测到 CentOS/RHEL sudo yum install -y curl git # 安装Node.js 18 curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash - sudo yum install -y nodejs elif [ -f /etc/debian_version ] || grep -qi ubuntu /etc/os-release; then echo 检测到 Debian/Ubuntu sudo apt-get update sudo apt-get install -y curl git curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs else echo 不支持的发行版请手动安装Node.js 18 exit 1 fi echo Node.js: $(node --version) # 配置npm镜像 sudo npm config set registry https://registry.npmmirror.com # 克隆安装 cd ~ if [ ! -d ~/openclaw ]; then git clone https://github.com/nicepkg/openclaw.git fi cd ~/openclaw npm install # 配置 mkdir -p ~/.qclaw if [ ! -f ~/.qclaw/.env ]; then read -p 请输入API Key: KEY echo ZHIPU_API_KEY$KEY ~/.qclaw/.env fi # 注册systemd服务 sudo tee /etc/systemd/system/openclaw.service /dev/null EOF [Unit] DescriptionOpenClaw Gateway Afternetwork.target [Service] Typesimple User$(whoami) WorkingDirectory$HOME/openclaw ExecStart$(which node) gateway.js Restartalways RestartSec10 EnvironmentNODE_ENVproduction [Install] WantedBymulti-user.target EOF sudo systemctl daemon-reload sudo systemctl enable openclaw sudo systemctl start openclaw echo echo 安装完成 echo 服务状态 sudo systemctl status openclaw --no-pager echo echo 访问地址http://$(hostname -I | awk {print $1}):3456 echo echo 常用命令 echo 查看状态sudo systemctl status openclaw echo 查看日志sudo journalctl -u openclaw -f echo 重启服务sudo systemctl restart openclaw echo 停止服务sudo systemctl stop openclaw使用方法chmod x install_openclaw.sh ./install_openclaw.sh脚本会自动检测系统发行版、安装Node.js、克隆项目、配置服务。输入API Key后全自动完成。注意确保服务器能访问外网。如果npm install超时脚本里已经配了国内镜像。防火墙需要放行3456端口# CentOS/RHEL sudo firewall-cmd --permanent --add-port3456/tcp sudo firewall-cmd --reload # Ubuntu/Debian (ufw) sudo ufw allow 3456