本地yum配置
- 确认系统是否安装yum程序
rpm -qa | grep yum
- 配置yum源
cd /etc/yum.repos.d/
tar -zcvf CentOS_bak.tar.gz ./*
touch cdrom.repo
vim cdrom.repo
文件内容:
# 标记
[cdrom]
# 名称
name=cdrom
# 源路径(关盘的挂载点)
baseurl=file:///dedia
# 启用源文件
enabled=1
# 不检查源包
gpgcheck=0
- 检查可用源码包
yum list
- 安装
yum install -y gcc
网络yum配置
yum install -y wget
&& mkdir -p /etc/yum.repos.d/repo_bak
&& mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo_bak/
&& wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
&& wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
&& yum clean all && yum makecache
命令解读:
# 安装wegt
yum install -y wget
# 创建一个备份目录
mkdir -p /etc/yum.repos.d/repo_bak
# 备份
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo_bak/
# 从阿里云下载文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 清除yum缓存
yum clean all
# 生成缓存
yum makecache
其他yum源:
163:
http://mirrors.163.com/.help/CentOS7-Base-163.repo
http://centos.ustc.edu.cn/CentOS-Base.repo
清华:
https://mirrors.cnnic.cn/help/centos/