参考: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/

为本地存放rpm包的目录创建repodata

createrepo -g comps.xml /var/www/html/repos/base/
createrepo comps.xml /var/www/html/repos/centosplus/
createrepo comps.xml /var/www/html/repos/extras/
createrepo comps.xml /var/www/html/repos/updates/

修改/etc/nginx/nginx.conf文件server段

server {
listen default_server;
listen [::]: default_server;
server_name _;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
root /var/www/html/repos;
index index.php index.html index.htm;
autoindex on; #enable listing of directory index
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

保存并重启Nginx

步骤三:检查本地Yum仓库

但是进入到具体目录看不到rpm包

基于CentOS构建企业镜像站的更多相关文章

  1. DevOps实践之一:基于Docker构建企业Jenkins CI平台

    基于Docker构建企业Jenkins CI平台 一.什么是CI 持续集成(Continuous integration)是一种软件开发实践,每次集成都通过自动化的构建(包括编译,发布,自动化测试)来 ...

  2. 微服务架构 - 基于Harbor构建本地镜像仓库

    之前写过<搭建docker本地镜像仓库并提供权限校验及UI界面>文章,然后有同仁评论道这样做太复杂了,如果Harbor来搭建会更简单同时功能也更强大.于是抽时间研究了基于Harbor构建本 ...

  3. (转)基于OpenStack构建企业私有云(1)实验环境准备

    原文:https://www.unixhot.com/article/407 https://www.cnblogs.com/kevingrace/p/5707003.html-----完整部署Cen ...

  4. 基于url-to-pdf-api构建docker镜像,制作一个网页另存服务

    基于url-to-pdf-api构建docker镜像,制作一个网页另存服务 业务背景: 需要根据一个url路径打印这个网页的内容 解决方案: 1.使用wkhtml2pdf 2.使用puppeteer ...

  5. 基于Kubernetes构建企业Jenkins master/slave CI/CD平台

    搭建平台目的: k8s中搭建jenkins master/slave架构,解决单jenkins执行效率低,资源不足等问题(jenkins master 调度任务到 slave上,并发执行任务,提升任务 ...

  6. 基于Kubernetes构建企业容器云

    前言 团队成员有DBA.运维.Python开发,由于需要跨部门向公司私有云团队申请虚拟机, 此时我在思考能否在现有已申请的虚拟机之上,再进行更加细粒度的资源隔离和划分,让本团队的成员使用, 也就是在私 ...

  7. CentOS更换aliyun镜像站

    目录 1. 官方地址 2. 社区文档 3. 镜像更换 3.1 配置方法: 3.1.1. 备份原配置文件 3.1.2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/ ...

  8. 基于centos 创建stress镜像——源码安装stress

    上一篇文章进行了yum安装stress,这次对stress进行源码编译安装,并且生成新的镜像 创建Dockerfile目录 [vagrant@localhost ~]$ mkdir -p /tmp/s ...

  9. 基于 Docker 构建企业 Jenkins CI平台

    持续集成(Continuous Integration,CI):代码合并.构建.部署.测试都在一起,不断地执行这个过程,并对结果反馈. 持续部署(Continuous Deployment,CD):部 ...

随机推荐

  1. Python - Django - Cookie 简单用法

    home.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  2. (十四)访问标志 Access_flags

    一.概念 上一章节讲到了常量池,如下图,常量池之后便是访问标志acess_flags,占2个字节(u2). 二.例子 编写一个接口. public interface Test{ public fin ...

  3. Intellij IDEA Debug 多模块下断点目标源问题

    Ctrl+Alt+S进入Settings,选择Debugger->show alternative source switcher 勾选,开启显示替代源选择器 由于项目工程存放了多个应用模块,包 ...

  4. Charles 抓包配置

    本文参考:charles 抓包配置 proxy setting (代理设置) 设置的主界面如下: 动态端口 启用动态端口选项来监听动态端口,每次查询启动时选择.这样可以避免与计算机上可能运行的其他网络 ...

  5. 【GStreamer开发】GStreamer基础教程05——集成GUI工具

    目标 本教程展示了如何在GStreamer集成一个GUI(比如:GTK+).最基本的原则是GStreamer处理多媒体的播放而GUI处理和用户的交互. 在这个教程里面,我们可以学到: 如何告诉GStr ...

  6. JAVA 读取xml格式的数据

    <?xml version="1.0" encoding="UTF-8"?> <column-enums> <type name= ...

  7. 【leetcode算法-简单】7.整数反转

    [题目描述] 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转. 示例 1: 输入: 123输出: 321 示例 2: 输入: -123输出: -321 示例 3: 输入: 12 ...

  8. STL常用

    nth_element(first,nth,last) first,last 第一个和最后一个迭代器,也可以直接用数组的位置. 将第n个大的元素放到nth位置上,左边元素都小于它,右边元素都大于它. ...

  9. 023 Android 自定义Toast控件

    1.Toast自定义控件工具类 package com.example.administrator.test62360safeguard.Utils; import android.content.C ...

  10. Python27之集合

    集合说:“在我的世界里,你就是唯一” 一.集合的概念和使用 集合的概念和数学里数学里集合的概念是一致的,都是一组元素的集,且元素之间不能重复.元素必须是不可变的数据类型,例如元组也可以作为其中的一个元 ...