centos7.x搭建http局域网yum源

##先创建一个目录,作为存在rpm包的目录
centos7.x搭建http局域网yum源

##挂载ISO镜像到/mnt/目录,拷贝ISO镜像文件中的rpm包到/data/yumdata/
centos7.x搭建http局域网yum源

##创建repository
系统默认没有createrepo命令,使用yum安装
centos7.x搭建http局域网yum源
centos7.x搭建http局域网yum源

如果rpm包有增加,需要执行createrepo --update /data/yumdata/
centos7.x搭建http局域网yum源

##安装nginx,提供http服务
安装扩展源yum install epel-release
centos7.x搭建http局域网yum源

##安装nginx服务yum install nginx
centos7.x搭建http局域网yum源

##配置nginx.conf,使其可以通过IP地址访问到/data/yumdata
进入nginx配置文件,vim /etc/nginx/nginx.conf,修改以下内容
centos7.x搭建http局域网yum源

##保存退出,启动服务,并测试服务是否正常运行
centos7.x搭建http局域网yum源

##使用web访问服务器IP
centos7.x搭建http局域网yum源

##客户端上配置repo文件,先安装rsync工具,yum install rsync
centos7.x搭建http局域网yum源

##返回上级目录,cd /etc/yum.repos.d/ , 创建my.repo文件,vim my.repo //添加内容如下
centos7.x搭建http局域网yum源

##做一个镜像yum源
比如可以把系统默认的源给镜像到局域网来,思路是用rsync工具把远程的rpm包同步到这台局域网的对应目录下即可。
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/ /data/yumdata/
centos7.x搭建http局域网yum源
centos7.x搭建http局域网yum源

##当局域网的rpm库有更新时,除了服务端执行“createrepo –update
/data/yumdata/”外,客户端上也需要执行
yum clean all //删除缓存