Create yum repository

In this tutorial we’ll explain how to set up a yum rpm repository for your Red Hat/CentOS Server.

At first you need to set up a web directory for the repository using your preferred web server. In this example
we’ll be using the Apache2 server.

Install apache2 by running following command. While at it, also install ‘createrepo’, a package needed to create the needed xml files for your repo.

sudo yum install httpd createrepo

The httpd config for the repository is pretty straight forward. A simple config would look like this:

    Listen IP:80

    <VirtualHost IP:80>
    ServerName //Insert your address here
    DocumentRoot /var/repo

    <Directory /var/repo>
        Options Indexes

    ErrorLog /var/log/httpd/repo_error.log
    LogLevel debug

    CustomLog /var/log/httpd/repo_access.log combined


Save the config at /etc/httpd/conf.d/repo.conf, create following directory,

mkdir -p /var/repo/main/RPMS

then restart the httpd server, using

sudo service httpd restart

Make sure that the config is correct by checking if the server is accessible. Use a browser and go to and see if it comes up without a problem.

Once it’s running, create a config file for the repository, in


and insert following

name=My Main RPM Repository

You can add more repositories to the config, e.g.

name=My alternative RPM Repository

and so forth.

Once done, save the file.

Now, move your RPMs into /var/repo/main/RPMS and run

createrepo /var/repo/main

If you have set up another repo in the config file, run the command for each sub directory, e.g.

createrepo /var/repo/alt

This will create a directory called ‘repodata’ containing all necessary info on the yum repo in xml format.
Run this command every time you add new rpm files to your reposotitory.

Now, run

sudo yum clean all

followed by another yum command, such as

sudo yum info httpd

to see if yum picks up on your repo.

If your repo appears in the list and no problems are found, your repository is up and running.

This way, your repo is open to the public.
If you don’t want your repo accessible to the public, you can set up an http auth for your directory, and edit your repo.conf in the following way:


Equally if you want to run your repo through https, just adjust your config as well, and it works.

In another post we’ll go through creating rpm files.