How to Setup Local HTTP Yum Repository on CentOS 7

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

23 Responses

  1. jrp says:

    Installed and configured nginx according to your guide. Changed the server name and restarted the vm, but when I try to go to the url I get error 403 forbidden.

    At first I was getting the standard index.html screen saying nginx is installed but not setup. After renaming the index.html file I get the 403 error. I checked selinux thinking this may be the issue, but it doesn’t appear to be the problem. Any suggestions?

  2. Chris says:

    When copying and pasting the cron.daily script, make sure the quotation marks are pasted correctly. My daily script wasn’t running and I couldn’t see why until I ran it manually. It threw this error:

    /etc/cron.daily/update-localrepos: line 3: centosplus: command not found
    

    Turns out the quotation marks were smart-quotes, i.e. those ones browsers and some editors change normal quotes to.

    Changed them to proper quotes, retested – now all good.

  3. Amara says:

    Hello I have a problem, when I run the command “yum repolist” I have This and I had tried to install Firefox to test the local repository but it doesn’t worked..

    Loaded add-ons: fastestmirror
    base | 3.6 kB 00:00
    extras | 3.4 kB 00:00
    http://172.16.1.2/base/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Try another mirror.
    http://172.16.1.2/base/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Try another mirror.
    http://172.16.1.2/centosplus/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Try another mirror.
    http://172.16.1.2/extras/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Try another mirror.
    http://172.16.1.2/updates/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Try another mirror.
    updates / 7 / x86_64 | 3.4 kB 00:00
    deposit ID deposit name status
    base / 7 / x86_64 CentOS-7 - Base 10 019
    extras / 7 / x86_64 CentOS-7 - Extras 382
    local-base CentOS Base 0
    local-centosplus CentOS CentOSPlus 0
    local-extras CentOS Extras 0
    local-updates CentOS Updates 0
    updates / 7 / x86_64 CentOS-7 - Updates 1 459
    repolist: 11,860

  4. Pat Mole says:

    How to use this for AltArch mirroring?

  5. cody says:

    I followed the tutorial and when groupfile failed, I used touch command to have a comps.xml file however i keep getting Failed to add groups file for repository: local-extras – comps file is empty/damaged

  6. Seyed Hossein Mirheydari says:

    I corrected the “update-localrepos” file to “Synchronize and Create Repositories” as below:

    #!/bin/bash
    ##specify all local repositories in a single variable
    LOCAL_REPOS='base centosplus extras updates'
    ##a loop to update repos one at a time 
    for REPO in ${LOCAL_REPOS}; do
    reposync -g -l -d -m --repoid=$REPO --newest-only --download-metadata --download_path=/var/www/html/repos/
    
    if [ $REPO = 'base' ]
    then
    createrepo -g comps.xml /var/www/html/repos/$REPO/  
    else
    createrepo /var/www/html/repos/$REPO/  
    fi
    

    done

  7. Shaul Marcus says:

    I am having the same problem. When I run createrepo -g comps.xml /var/www/html/repos/base it works fine. When I try run on the other directories it gives me Error: groupfile /var/www/html/repos/centosplus/comps.xml cannot be found.

    The comps.xml file only exists in the base and when I try to pull it from the other repos, nothing happens.

    Any help would be much appreciated.

  8. Abdul Rafi says:

    Hi, I followed the whole procedure of creating a local yum repository and added it to the client machine. But after running the yum repolist command on the client machine it gives me errors and show 0 packages for the local base:

    [[email protected] ~]# yum repolist
    Loaded plugins: fastestmirror, langpacks
    http://repo.dev.local/base/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.
    http://repo.dev.local/base/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.
    http://repo.dev.local/centosplus/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.
    http://repo.dev.local/extras/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.
    http://repo/dev/local/updates/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.
    repo id           repo name                            status
    base/7/x86_64     CentOS-7 - Base                      9,911
    extras/7/x86_64   CentOS-7 - Extras                    433
    local-base        CentOS Base                          0
    local-centosplus  CentOS CentOSPlus                    0
    local-extras      CentOS Extras                        0
    local-updates     CentOS Updates                       0
    updates/7/x86_64  CentOS-7 - Updates                   1,614
    repolist: 11,958
    
  9. Tony Sarles says:

    I found that nginx couldn’t read the repo folders. This is apparently an SELinux thing. The following commands resolved the issue:

    # yum install -y policycoreutils-devel
    # grep nginx /var/log/audit/audit.log | audit2allow -M nginx
    # semodule -i nginx.pp
    
  10. virgilhsu says:

    Thanks for your share, I have do it by your solution step by step, but when I run the following command.

    # createrepo -g comps.xml /usr/share/nginx/html/repos/centosplus/
    
    Error: groupfile /usr/share/nginx/html/repos/centosplus/comps.xml cannot be found.
    

    In my Nginx root directory /usr/share/nginx/html, I run the following command.

    # createrepo  /usr/share/nginx/html/repos/centosplus/
    

    It`s done by no problem,finally, I run this command in a client centos7 pc:

    # yum repolist
    
    http://172.16.1.91/repos/base/repodata/repomd.xml: [Errno 12] Timeout 
    on http://172.16.1.91/repos/base/repodata/repomd.xml: 
    (28, 'Connection timed out after 30001 milliseconds')
    Trying other mirror.
    

    The 172.16.1.91 is the repos server,how to fix this problem?

    • Aaron Kili says:

      @virgilhsu

      Did you add the local repo config on the client machine as shown? If yes, did you use the correct URL for all the repos? Is your client able to connect to the server, you can check using ping command.

    • jordan says:

      just touch the comps.xml file, worked for me.

      • LivingLegend says:

        Hi, this isn’t solution. You are created only empty file.

        This procedure isn’t correctly:

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

        only base contains comps.xml

        This is correctly procedure:

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

        I find solution on https://www.centos.org/forums/viewtopic.php?t=61184

        • Aaron Kili says:

          @LivingLegend

          Thanks for sharing, we’ll look at it.

        • Spacerat says:

          Which in turn leads to problems with the updater cron script

          Loaded plugins: fastestmirror
          Loading mirror speeds from cached hostfile
          Warning: cannot find repository base
          No repositories found
          Spawning worker 0 with 5010 pkgs
          Spawning worker 1 with 5009 pkgs
          Workers Finished
          Saving Primary metadata
          Saving file lists metadata
          Saving other metadata
          Generating sqlite DBs
          Sqlite DBs complete
          Loaded plugins: fastestmirror
          Loading mirror speeds from cached hostfile
          Warning: cannot find repository centosplus
          No repositories found
          Error: groupfile /var/www/html/repos/centosplus/comps.xml cannot be found.
          Loaded plugins: fastestmirror
          Loading mirror speeds from cached hostfile
          Warning: cannot find repository extras
          No repositories found
          Error: groupfile /var/www/html/repos/extras/comps.xml cannot be found.
          Loaded plugins: fastestmirror
          Loading mirror speeds from cached hostfile
          Warning: cannot find repository updates
          No repositories found
          Error: groupfile /var/www/html/repos/updates/comps.xml cannot be found.
          

          because it is called with -g comps.xml for each repo, not really sure what is the right way here.

          Additionally i also need to host centos6 rpms on the same server but did not yet look into that.

Leave a Reply to virgilhsu Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.