一.联网条件下,配置网络yum源
1.linux操作好习惯,做操作的时候要做好文件备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.以阿里的CentOS-Base.repo为例,在linux命令行输入以下命令:
查看本机系统
cat /etc/issue
对应自己本机的系统版本,选择以下操作
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
其他yum源地址
CentOS 5
中科大:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.ustc.edu.cn/centos/CentOS-Base.5.mirrors.repo -O/etc/yum.repos.d/CentOS-Base.repo
163:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base.163.rep
CentOS 6
163:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base.163.rep
手动配置yum源文件
http://tiger.im/49.html 这篇文章写的很详细,可以参考
3.测试
yum clean all
yum makecache
yum list/或者下载yum install vim
二.本地条件下,配置本地yum源
以虚拟机环境下为例
1.将装机的iso文件连接上虚拟机(相当于插上u盘的操作)
(为了方便以后使用可以在设置里面设置设备开机挂载)
2.挂载到指定目录
mount -o loop -t iso9660 /dev/dvd1 /mnt/cdrom
3.创建新的repo文件
vim CentOS-Media.rep
输入以下(主要修改两个file:///你的挂载点)
[c6-media]
name=CentOS-local
baseurl=file:///mnt/cdrom
gpgcheck=1
enabled=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-6
4.测试
yum clean all
yum makecache
yum list/或者下载yum install vim