centos7.0/rhel7.0安装gcc7

CentOS 7 已于 2024年6月30日 正式停止官方支持,官方的 yum 仓库已停止更新,甚至部分源已下线或不可访问。
不过,社区和第三方提供了一些可用的镜像源来继续支持 CentOS 7 用户。

# 备份旧的 repo

mkdir /etc/yum.repos.d/old
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/old/

# 下载新的 repo 文件
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# 清除缓存并重建缓存
yum clean all
yum makecache

在 CentOS 7 上安装 devtoolset-7

第一步:安装 Software Collections (SCL) 支持包

yum install -y centos-release-scl

第二步:安装 devtoolset-7

yum install -y devtoolset-7 devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils

第二步可能提示如下错误:

【yum install -y devtoolset-7 devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils Loaded plugins: fastestmirror Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Name or service not known" One of the configured repositories failed (Unknown), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Disable the repository, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable <repoid> 4. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64】

是由于 CentOS 7 的 SCLo 仓库默认配置使用了 mirrorlist.centos.org,但该域名在 2024 年官方 EOL 后 已失效,所以 yum 无法解析镜像地址。

解决方法:

手动创建并写入有效配置SCLo 源(使用阿里云)

复制以下所有内容在SHELL终端执行。 

 CentOS-SCLo-scl-rh.repo

cat > /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo <<EOF
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
enabled=1
gpgcheck=0

[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh - Source
baseurl=https://mirrors.aliyun.com/centos/7/sclo/Source/rh/
enabled=0
gpgcheck=0
EOF

CentOS-SCLo-scl.repo

cat > /etc/yum.repos.d/CentOS-SCLo-scl.repo <<EOF
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
enabled=1
gpgcheck=0

[centos-sclo-sclo-source]
name=CentOS-7 - SCLo sclo - Source
baseurl=https://mirrors.aliyun.com/centos/7/sclo/Source/sclo/
enabled=0
gpgcheck=0
EOF

 

然后再执行

yum clean all
yum makecache

yum install -y devtoolset-7 devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值