搭建本地yum源

在局域网内搭建yum源

挂载镜像

配置

1
2
3
4
mkdir /mnt/cdrom

mount -t iso9660 -o,loop /dev/sr0 /mnt/cdrom
ll /mnt/cdrom/

配置本地yum仓库

1
2
3
4
5
6
7
8
9
10
11
12
cd /etc/yum.repos.d/
rename .repo .repo.bak *
vi CentOS-Local.repo

[base]
name=CentOS-Local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1

yum clean all
yum repolist

配置nginx

1
2
3
4
5
yum install nginx.x86_64 -y
cp -r /mnt/cdrom/Packages /mnt/cdrom/repodata /usr/share/nginx/html/centos/7/os/x86_64

# 卸载镜像
umount /mnt/cdrom

本地yum源路径修改

1
2
3
4
5
6
7
8
9
vi /etc/yum.repos.d/CentOS-Local.repo
[base]
name=CentOS-Local
baseurl=file:///usr/share/nginx/html/centos/7/os/x86_64
gpgcheck=0
enabled=1

yum clean all
yum repolist

启动nginx

1
2
3
4
5
6
7
8
vi /etc/nginx/nginx.conf

location / {
autoindex on;
}

systemctl start nginx
systemctl stop firewalld

其他机器yum配置

1
2
3
4
5
6
7
8
9
10
cd /etc/yum.repos.d
rename .repo .repo.bak *

vi CentOS-Local.repo

[base]
name=CentOS-Local-Base
baseurl=http://192.168.33.201/centos/7/os/x86_64
enabled=1
gpgcheck=0