搭建本地yum源

By | 2018年2月9日

1.挂载镜像

mkdir /mnt/cdrom

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

2.配置本地yum仓库

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

3.配置nginx

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`

4.本地yum源路径修改

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

5.启动nginx

vi /etc/nginx/nginx.conf

location / {
    autoindex on;
}

systemctl start nginx
systemctl stop firewalld

6.其他机器yum配置

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

发表评论