可以的,CentOS 完全可以用来配置 Rust 开发环境。下面我按推荐方式 + 常见坑给你一个完整说明,适用于 CentOS 7 / 8 / Stream。
rustup(官方方式 ✅)这是 最推荐、最干净、最灵活 的方式。
CentOS 默认可能缺少编译工具:
sudo yum groupinstall -y "Development Tools"
sudo yum install -y gcc gcc-c++ make openssl openssl-devel
如果是 CentOS 8 / Stream:
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y gcc gcc-c++ openssl-devel
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装过程中选择:
1) Proceed with installation (default)
安装完成后:
source ~/.cargo/env
验证:
rustc --version
cargo --version
编辑 ~/.cargo/config.toml(没有就新建):
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
或使用清华镜像:
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
cargo new hello_rust
cd hello_rust
cargo run
输出:
Hello, world!
✅ 说明 Rust 开发环境已成功配置。
rustup component add rust-analyzer
openssl 错误sudo yum install -y openssl-devel
rustup install 1.75.0
rustup default 1.75.0
✅ CentOS 完全可以配置 Rust 开发
✅ 推荐 rustup 安装
✅ 注意 gcc / openssl 依赖
✅ 国内一定配镜像
如果你愿意,我可以:
你现在是 物理机 / 虚拟机 / 云服务器?