在 CentOS 上配置 Rust 的耗时,主要取决于网络速度、CentOS 版本、是否使用代理、是否编译依赖这几个因素。下面给你一个大致时间参考(普通云服务器/虚拟机场景):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
耗时参考:
✅ 只包含 rustc / cargo / rustup,不编译项目
export RUSTUP_DIST_SERVER=https://rsproxy.cn
export RUSTUP_UPDATE_ROOT=https://rsproxy.cn/rustup
或写进 ~/.bashrc
效果:
rustup component add rustfmt clippy
耗时:
cargo new demo && cd demo && cargo build
⚠️ Rust 编译慢是特点,不是配置问题
yum install -y gcc make openssl-devel
否则编译时会报错
| 场景 | 耗时 |
|---|---|
| 安装 rustup | 1–5 分钟 |
| 配置镜像 | 1 分钟 |
| hello world | <1 分钟 |
| 中型项目首次编译 | 5–20 分钟 |
| 大型项目首次编译 | 30 分钟+ |
如果你愿意,可以告诉我:
我可以给你最优安装方案。