龙虾一键部署脚本,3分钟搞定OpenClaw环境
·
我是个懒人。安装软件的时候如果能少敲一行命令,我就绝不多敲。OpenClaw的安装其实已经很简单了,但如果你是那种连"打开终端"都嫌麻烦的人,那这个一键部署脚本就是为你准备的。我自己写了一个,经过多台机器测试,这里分享出来。
OpenClaw最新版本一键部署包下载地址:https://top.wokk.cn/
脚本做了什么
本质上就是把手动安装的步骤自动化了:
1. 检测系统环境和已有依赖
2. 安装Node.js(如果没有)
3. 克隆OpenClaw源码
4. 安装npm依赖
5. 创建配置目录和.env文件
6. 启动Gateway
整个过程全自动,你只需要跑一条命令然后等它跑完。实测在一般的网络环境下(配了镜像源),5分钟以内搞定。
Windows一键脚本
新建一个文件叫 install-openclaw.ps1,内容如下:
# OpenClaw一键安装脚本 (Windows)
Write-Host "=== OpenClaw 一键部署 ===" -ForegroundColor Green
# 检查Node.js
$nodeVer = $null
try { $nodeVer = node --version } catch {}
if (-not $nodeVer) {
Write-Host "未检测到Node.js,正在安装..." -ForegroundColor Yellow
winget install OpenJS.NodeJS.LTS
# 刷新环境变量
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
}
Write-Host "Node.js版本: $nodeVer" -ForegroundColor Cyan
# 配置npm镜像
npm config set registry https://registry.npmmirror.com
# 克隆项目
if (-not (Test-Path "$env:USERPROFILE\openclaw")) {
git clone https://github.com/nicepkg/openclaw.git "$env:USERPROFILE\openclaw"
}
cd "$env:USERPROFILE\openclaw"
# 安装依赖
npm install
# 创建配置
$qclawDir = "$env:USERPROFILE\.qclaw"
if (-not (Test-Path $qclawDir)) { New-Item -ItemType Directory -Path $qclawDir }
$envFile = "$qclawDir\.env"
if (-not (Test-Path $envFile)) {
$key = Read-Host "请输入你的API Key(去 open.bigmodel.cn 获取)"
Set-Content -Path $envFile -Value "ZHIPU_API_KEY=$key" -Encoding UTF8
}
# 启动
Write-Host "启动Gateway..." -ForegroundColor Green
npm run gateway
用PowerShell运行这个脚本:
Set-ExecutionPolicy Bypass -Scope Process
.\install-openclaw.ps1
脚本会在需要你输入API Key的地方暂停,你粘贴Key后它就会继续自动跑完。
macOS/Linux一键脚本
#!/bin/bash
# OpenClaw一键安装脚本 (macOS/Linux)
echo "=== OpenClaw 一键部署 ==="
# 检查Node.js
if ! command -v node &>/dev/null; then
echo "未检测到Node.js,正在安装..."
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install node@18
else
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
fi
echo "Node.js: $(node --version)"
# 配置npm镜像
npm config set registry https://registry.npmmirror.com
# 克隆项目
if [ ! -d ~/openclaw ]; then
git clone https://github.com/nicepkg/openclaw.git ~/openclaw
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
# 启动
echo "启动Gateway..."
npm run gateway
保存为 install-openclaw.sh,然后:
chmod +x install-openclaw.sh
./install-openclaw.sh
脚本使用注意事项
1. 运行前确保有网络连接
2. Windows用户需要PowerShell 5.1+
3. 如果Node.js已安装但版本低于18,脚本不会自动降级升级
需要手动升级后再运行
4. 脚本执行过程中不要中断(Ctrl+C)
5. 脚本会配置npm镜像,如果你之前有自定义镜像会被覆盖
一键脚本的本质就是自动化。如果你是第一次装、或者需要经常在新机器上部署,这个脚本能省不少时间。但如果只是装一次,手动安装其实也就几分钟的事。
更多推荐




所有评论(0)