4.3. 创建新的 Web 服务器以托管仓库

如果您没有现有的 Web 服务器来托管您的仓库,请使用同步的仓库创建一个。

流程

如果创建新的 Web 服务器,请使用以下步骤。

  1. 安装先决条件:

    $ sudo dnf install httpd
  2. 将 httpd 配置为提供 repo 目录:

    /etc/httpd/conf.d/repository.conf
    
    DocumentRoot '/path/to/repos'
    
    <LocationMatch "^/+$">
        Options -Indexes
        ErrorDocument 403 /.noindex.html
    </LocationMatch>
    
    <Directory '/path/to/repos'>
        Options All Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
  3. 确保 apache 用户可读该目录:

    $ sudo chown -R apache /path/to/repos
  4. 配置 SELinux:

    $ sudo semanage fcontext -a -t httpd_sys_content_t "/path/to/repos(/.*)?"
    $ sudo restorecon -ir /path/to/repos
  5. 启用 httpd :

    $ sudo systemctl enable --now httpd.service
  6. 打开防火墙:

    $ sudo firewall-cmd --zone=public --add-service=http –add-service=https
    --permanent
    $ sudo firewall-cmd --reload
  7. 在自动化控制器和自动化中心中,在 /etc/yum.repos.d/local.repo 中添加一个仓库文件(如果需要,请添加可选的仓库):

    [Local-BaseOS]
    name=Local BaseOS
    baseurl=http://<webserver_fqdn>/rhel-8-for-x86_64-baseos-rpms
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    
    [Local-AppStream]
    name=Local AppStream
    baseurl=http://<webserver_fqdn>/rhel-8-for-x86_64-appstream-rpms
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release