1、安装环境
cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
2、备份本地原来的repo文件
cd /etc/yum.repos.d/
mkdir repo_bak
mv *.repo repo_bak/
3、配置网易和阿里的开源镜像
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
4、清除系统yum缓存并生成新的yum缓存
清除缓存
yum clean all
生成新缓存
yum makecache
5、安装epel源
执行yum命令安装
yum install -y epel-release
6、使用阿里开源镜像提供的epel源
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
7、再次清除缓存,生成新缓存
清除缓存
yum clean all
生成新缓存
yum makecache
更新
yum update -y
8、安装完成
装一个gcc
yum install -y gcc
查看gcc版本
gcc -v
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)