准备材料:

  • 1, CentOS-7-x86_64-DVD-1810.iso
  • 2, 安装 httpd
  • 3,重新编辑 /etc/yum.repos.d/CentOS-Base.repo
  • 4, 使用新的仓库地址: yum clean all && yum makecache && yum list

1,下载centos7软件集成镜像

https://mirrors.tuna.tsinghua.edu.cn/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso

2,安装httpd服务

( 使用http提供本地网络访问资源文件)

[[email protected] yum.repos.d]# yum -y install httpd && service httpd start
[[email protected] yum.repos.d]# lsof -i:80
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   14456   root    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14457 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14458 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14459 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14460 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14461 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14462 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14463 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14466 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14467 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)
httpd   14468 apache    4u  IPv6  43691      0t0  TCP *:http (LISTEN)

3, 挂载iso文件到http的访问目录

#http配置文件:  /etc/httpd/conf/httpd.conf
# DocumentRoot "/var/www/html"

[[email protected] ~]# mkdir /var/www/html/centos7/
[[email protected] yum.repos.d]# mount ~/CentOS-7-x86_64-DVD-1810.iso /var/www/html/centos7/

centos7: 搭建本地yum仓库

4, 重新编辑repo文件

[[email protected] yum.repos.d]#mkdir back
[[email protected] yum.repos.d]# mv *.repo back 

#编辑新的Centos-Base.repo文件,内容如下
[[email protected] yum.repos.d]# cat CentOS-Base.repo 
[base]
name=myrepo
baseurl=http://s101:80/centos7/
enabled=1
gpgcheck=0
gpgkey=http://s101:80/centos7/RPM-GPG-KEY-CentOS-7

5,创建仓库缓存

[[email protected] yum.repos.d]# yum clean all
[[email protected] yum.repos.d]#  yum makecache

centos7: 搭建本地yum仓库

相关文章: