Skip to content
OPS技术笔记 / Linux

CentOS 7 升级 GCC 版本至 8.3.1

在 CentOS 7 上通过 CentOS SCL 方式将 GCC 从 4.8.5 升级到 8.3.1,包含国内阿里云镜像源配置、安装验证等完整步骤。

J
Jasper Labs· 2026年3月20日
``

shell
yum install centos-release-scl

shell
# 备份
mv /etc/yum.repos.d/CentOS-SCLo-scl.repo  /etc/yum.repos.d/CentOS-SCLo-scl.repo.bak
# 写入阿里源
vim /etc/yum.repos.d/CentOS-SCLo-scl.repo
shell
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
# mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SC
shell
# 备份
mv /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo  /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo.bak
# 写入阿里源
vim /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
shell
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
# mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
shell
yum clean all

shell
yum install devtoolset-8

shell
scl enable devtoolset-8 bash
``````

shell
gcc --version
``

INFO

DISCUSS

评论与讨论

如果这篇文章对你有帮助,或你对实现细节有不同判断,可以直接在这里继续讨论。