参考:How to Setup Local HTTP Yum Repository on CentOS 7
实验环境
CentOS7 1804
步骤一:安装Nginx Web Server
最小化安装后替换Yum源为163源:http://mirrors.163.com/.help/centos.html
yum clean all
yum makecache
安装epel和nginx
yum install epel-release
yum install nginx
启用Nginx并设置开机自动启动
systemctl start nginx
systemctl enable nginx
systemctl status nginx
设置防火墙,允许http,https
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --reload
步骤二:创建本地Yum仓库
安装必要包,用于创建、配置、管理本地仓库
yum install createrepo yum-utils
创建存储rpm包的目录
mkdir -p /var/www/html/repos/{base,centosplus,extras,updates}
同部远程yum仓库的包到本地yum仓库
reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/var/www/html/repos/ reposync -g -l -d -m --repoid=centosplus --newest-only --download-metadata --download_path=/var/www/html/repos/ reposync -g -l -d -m --repoid=extras --newest-only --download-metadata --download_path=/var/www/html/repos/ reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/var/www/html/repos/