Debian部署OpenClaw
系统版本Debian12.13
环境准备
创建用户openclawadduser openclaw
安装Curl、Unzip、Polkit、CMake、Sudo、Gitapt install curl unzip policykit-1 cmake sudo git
添加用户openclaw到sudo组usermod -aG sudo openclaw
如果国内的网络环境,建议配置网络代理后进行后续步骤,国内无代理参考无代理部分的命令
安装go 1.23
有代理
wget https://dl.google.com/go/go1.23.0.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
tee -a /etc/profile <<< 'export PATH=$PATH:/usr/local/go/bin' > /dev/null无代理
wget https://golang.google.cn/dl/go1.23.0.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
tee -a /etc/profile <<< 'export PATH=$PATH:/usr/local/go/bin' > /dev/null切换openclaw用户进行后续步骤
Go设置代理(无代理环境)
设置代理go env -w GOPROXY=https://goproxy.cn,direct
删除代理go env -u GOPROXY
查看代理设置go env GOPROXY
安装Homebrew
有代理
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"禁用Homebrew自动更新
echo 'export HOMEBREW_NO_AUTO_UPDATE=1' >> ~/.profile
source ~/.profile无代理
sudo mkdir -p /home/linuxbrew/.linuxbrew
sudo chown -R $(whoami) /home/linuxbrew
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git /home/linuxbrew/.linuxbrew/Homebrew
mkdir -p /home/linuxbrew/.linuxbrew/bin
ln -s /home/linuxbrew/.linuxbrew/Homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin/
mkdir -p /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"设置国内镜像源
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"' >> ~/.profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"' >> ~/.profile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> ~/.profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.profile
source ~/.profile禁用Homebrew自动更新
echo 'export HOMEBREW_NO_AUTO_UPDATE=1' >> ~/.profile
source ~/.profile查看国内镜像源是否生效
执行命令brew config
输出里的以下字段就是镜像源
HOMEBREW_API_DOMAIN
HOMEBREW_BOTTLE_DOMAIN
HOMEBREW_BREW_GIT_REMOTE
HOMEBREW_CORE_GIT_REMOTE
执行OpenClaw安装脚本(后续版本更新也使用这个脚本)
curl -fsSL https://openclaw.ai/install.sh | bash
版本更新
openclaw update
切换更新渠道
openclaw update --channel beta
openclaw update --channel dev
openclaw update --channel stable版本降级(升级后出现BUG可以降级到老版本)
查看可用版本
https://www.npmjs.com/package/openclaw?activeTab=versions
npm install -g openclaw@2026.2.9
openclaw gateway restart安装完成后,执行命令进入设置向导
openclaw onboard --install-daemon
设置代理(skills安装慢、安装失败时使用)
设置临时的Socks5代理,当前会话有效export all_proxy=socks5h://192.168.0.1:1080
NPM换源(skills安装慢、安装失败时使用)
换淘宝源npm config set registry https://registry.npmmirror.com
验证npm config get registry
换回官方源npm config set registry https://registry.npmjs.org
配置系统服务
sudo tee /etc/systemd/system/openclaw-gateway.service << 'EOF'
[Unit]
Description=OpenClaw Gateway
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/openclaw gateway --port 18789
Restart=always
RestartSec=5
Environment=OPENCLAW_GATEWAY_TOKEN=
WorkingDirectory=/home/openclaw
User=openclaw
[Install]
WantedBy=multi-user.target
EOFsudo systemctl daemon-reload
sudo systemctl enable --now openclaw-gateway.service