zoukankan      html  css  js  c++  java
  • 基于CentOS构建企业镜像站

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

    为本地存放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       80 default_server;
            listen       [::]:80 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 {
            }
        }
    View Code

    保存并重启Nginx

    步骤三:检查本地Yum仓库

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

     

  • 相关阅读:
    130行C语言实现个用户态线程库(2)
    130行C语言实现个用户态线程库(1)
    用C语言模仿Python函数
    ES 2.4 bigdesk 安装失败解决方案.
    使用SqlBulkCopy, 插入整个DataTable中的所有数据到指定数据库中
    表A的数据减去表B ,最终得到表C
    关于把A表中的数据复制到B表中(整理)
    需求池整理
    app主流推广渠道
    流程图梳理
  • 原文地址:https://www.cnblogs.com/kelamoyujuzhen/p/9936027.html
Copyright © 2011-2022 走看看