>最近服务器重装了,yum源也需要重新配置,记录一下
1、 删除/etc/yum.repos.d/文件夹下的所有以repo为后缀的文件
```
rm /etc/yum.repos.d/*.repo
```
2、 上传ISO镜像到服务器上
3、进行以下操作:
```
mkdir /mnt
mount -t iso9660 -o loop /data/centos_iso/CentOS-7-x86_64-DVD-2009.iso /mnt
mkdir -p /data/repos/centos
cp -r /mnt/Packages /data/repos/centos/
cp -r /mnt/repodata /data/repos/centos/
```
4、 配置nginx
```
server {
listen 65530;
server_name localhost;
location /centos {
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
root /data/repos;
}
}
```
前端访问
http://192.192.1.230:65530/centos/
显示的目录是:/data/repos/centos/

5、 配置yum源文件
```
cd /etc/yum.repos.d/
vi centos.repo
```
```
[centos]
name=centos
baseurl=http://192.192.1.230:65530/centos/
enabled=1
gpgcheck=0
```
6、 yum makecache生成缓存
```
yum clean all
yum makecache
```
**只需要在一台服务器上配置好就行,其他的服务器只需要执行 1/5/6 步骤即可**

服务器自建yum源