OpenClaw 零障碍安装:国内网络完全指南

最佳实践 6 分钟阅读 更新于 2026-05-19

OpenClaw 是一个 AI 编码助手代理,能够自主完成编码任务。

虽然网上已经有了很多搭建教程,但是一直没有完全满足我需求的方案——仅依赖国内网络,且仅参考官方原版文档,避免使用第三方魔改脚本。

核心思路:

  • Python 和 Node.js 环境需要灵活的工具来管理多版本——发行版自带的往往跟不上,所以需要用 fnmuv 这类工具管理 Python 和 Node.js;
  • cargo + 国内镜像源来安装那些官方安装脚本对网络有要求的工具(如 fnmuv),从而保证整个链路都在国内网络下畅通无阻。

1. 系统工具

1
apt install -y git curl wget build-essential ffmpeg

2. Rust 工具链

通过 rsproxy.cn 镜像安装 Rust,并配置 cargo 国内源:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh

cat > ~/.cargo/config.toml <<- 'EOM'
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
EOM

3. Node.js

用 cargo 安装 fnm(Node 版本管理),配合阿里云镜像:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cargo install --locked fnm

cat >> ~/.bashrc <<- 'EOM'

# fnm
export FNM_NODE_DIST_MIRROR="https://mirrors.aliyun.com/nodejs-release/"
eval "$(fnm env --use-on-cd --shell bash)"
EOM

# 新开 shell 或 source ~/.bashrc 后再执行以下命令
fnm use --install-if-missing 24
npm config set registry https://registry.npmmirror.com

cat >> ~/.bashrc <<- 'EOM'

# corepack
export COREPACK_NPM_REGISTRY=$(npm config get registry)
EOM

# 新开 shell 或 source ~/.bashrc
corepack enable pnpm
pnpm setup
npm install -g bun

cat >> ~/.bashrc <<- 'EOM'

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
export BUN_CONFIG_REGISTRY="https://registry.npmmirror.com"
EOM

4. uv (Python 包管理)

使用 cargo 安装 uv,并配置 PyPI 国内镜像:

1
2
3
4
5
6
7
cargo install --locked uv

cat > ~/.config/uv/uv.toml <<- 'EOM'
[[index]]
url = "https://mirrors.aliyun.com/pypi/simple"
default = true
EOM

5. OpenClaw

1
2
pnpm add -g --allow-build=openclaw openclaw@latest
openclaw onboard --install-daemon
标签: linux xops

如果这篇文章对您有帮助,欢迎打赏支持