第一步

搭建本地yum源仓库(需确保本地镜像成功挂载)

 rm -rf /etc/yum.repos.d/*

vim /etc/yum.repos.d/centos.repo

 [centos]

   name=centos

   baseurl=file:///opt/centos

 enabled=1

 gpgcheck=0


mkdir /opt/centos

mount /etc/cdrom /mnt

cp -rvf /mnt/* /opt/centos

umout /mnt

 

yum makecache   #生成本地源缓存


第二步 配置http源

yum -y install httpd

yum -y install createrepo*  #下载索引

mkdir /var/www/html/centos  

cd /var/www/html && chmod 777 -R centos

vim /etc/yum.repos.d/lan.repo

[lan]

name=lan

baseurl=http://本机ip/centos

enabled=1

gpgcheck=0


 #建立索引

cd /var/www/html/centos

createrepo centos


#关闭防火墙和SELINUX

systemctl stop firewalld

systemctl disable firewalld

vim /etc/selinux/config

SELINUX=Disabled


测试:

使用浏览器访问 http://本机ip/centos/centos/Packages

CentOS7如何搭建局域网源(http源)_html

出现以上界面,即为成功。