CentOS7 使用 centos-release-scl-rh yum库安装 devtoolset

  1. 用华为云镜像源替换 CentOS7 yum Base仓库
  • x86-64
bash 复制代码
curl -sL -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo

yum makecache
  • arm64
bash 复制代码
curl -sL -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-AltArch-7.repo

yum makecache
  1. 安装 centos-release-scl-rh 仓库
bash 复制代码
yum makecache
yum install -y centos-release-scl centos-release-scl-rh scl-utils
  1. 使用华为云镜像替换 centos-release-sclcentos-release-scl-rh 仓库地址
  • x86-64
bash 复制代码
# 移除 baseurl注释
sed -i "s/# *baseurl=/baseurl=/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
# 注释 mirrorlist
sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
# 更换仓库地址为华为云 centos-vault 镜像
sed -i "s/http:\/\/mirror.centos.org\/centos\/7/https:\/\/repo.huaweicloud.com\/centos-vault\/7.9.2009/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo

# 对 CentOS-SCLo-scl-rh.repo 执行同样的操作
sed -i "s/# *baseurl=/baseurl=/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sed -i "s/http:\/\/mirror.centos.org\/centos\/7/https:\/\/repo.huaweicloud.com\/centos-vault\/7.9.2009/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

yum makecache
yum search devtoolset # 搜索结果会显示多个 devtoolset 版本
  • arm64
bash 复制代码
# 移除 baseurl注释
sed -i "s/# *baseurl=/baseurl=/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
# 注释 mirrorlist
sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
# 更换仓库地址为华为云 centos-vault 镜像
sed -i "s/http:\/\/mirror.centos.org\/centos\/7/https:\/\/mirrors.huaweicloud.com\/centos-altarch\/7/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo

# 对 CentOS-SCLo-scl-rh.repo 执行同样的操作
sed -i "s/# *baseurl=/baseurl=/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
sed -i "s/http:\/\/mirror.centos.org\/centos\/7/https:\/\/mirrors.huaweicloud.com\/centos-altarch\/7/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

yum makecache
yum search devtoolset # 搜索结果会显示多个 devtoolset 版本
  1. 安装指定版本的 devtoolset
bash 复制代码
yum install -y devtoolset-8
  1. 验证安装
bash 复制代码
scl -l # 输出包含 devtoolset-8
scl enable devtoolset-8 bash # 切换到 devtoolset-8 的 bash
gcc -v # 输出包含 gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
相关推荐
鸠摩智首席音效师38 分钟前
linux 系统中 Shutting Down, Restarting, Halting 有什么区别 ?
linux·运维·服务器
CIb0la39 分钟前
Linux 将继续不支持 HDMI 2.1 实现
linux·运维·服务器
德生coding2 小时前
wifi驱动编译出来的驱动文件怎么做strip
linux
鹿鸣天涯2 小时前
Kali Linux 2025.4 发布:桌面环境增强,新增 3 款安全工具
linux·运维·安全
学习&笔记2 小时前
MTK(系统篇)user版本无法使用setenforce 0命令关闭selinux权限
linux·运维·服务器
Bdygsl3 小时前
Linux(8)—— 进程优先级与环境变量
linux·运维·服务器
another heaven3 小时前
【软考 磁盘磁道访问时间】总容量等相关案例题型
linux·网络·算法·磁盘·磁道
杨云龙UP4 小时前
MySQL 8.0.x InnoDB 写入链路优化:Redo Log 与 Buffer Pool 扩容与缓冲区调优实战记录-20251029
linux·运维·数据库·sql·mysql
txzz88885 小时前
CentOS-Stream-10 系统安装之网络设置
linux·运维·服务器·网络·计算机网络·centos
qq_401700415 小时前
嵌入式Linux网口MAC地址修改
linux·运维·macos