YUM repository configuration on CentOS/RHEL with Nginx

In production environment it might not possible to provide internet to all systems due to company policy or to control internet bandwidth. Installing a package from internet it might be slow because of low internet bandwidth. To overcome this issue we can configure a local yum server and put all the stuffs in the yum repository. Whenever there is a need to install a package it can be installed from the local repository. It saves a lots of internet bandwidth and as well as time.


  • YUM repository configuration on CentOS/RHEL with Nginx
  • How to configure YUM repository on CentOS/RHEL with Nginx?


YUM repository Prerequisites
  • Bare minimum install of Centos
  • Configuration
  • Here we configure the local yum server on Centos 7 operating system and will use client on both RHEL 6 and RHEL 7.

Server details

Server IP =
Host name = server.example.local
OS = CentOS 7.x

Install Nginx package to configure yum server

  • Add Nginx official repo to yum repository to install nginx package
# cd /etc/yum.repos.d/
# vim nginx.repo
name=nginx repo

  • Install NGINX package
# yum clean all
# yum makecache fast
# yum install nginx -y

NGINX Configuration for YUM repository

  • Take backup of default.conf file and create a new configuration file for yum repository.
# cd /etc/nginx/conf.d
# mv default.conf default.conf_bkp
# vim yum.conf
server {
    listen       80;
    server_name  server.example.local;

    charset koi8-r;
    access_log  /data/logs/host.access.log  main;

    location / {
        root   /data/www/html;
        index  index.html index.htm;

    error_page  404              /404.html;

   location /centos7 {
       alias /data/www/html/centos7/;
       autoindex on;

   location /centos6 {
       alias /data/www/html/centos6/;
       autoindex on;


  • Download installation image and mount it in any directory and copy into /data/www/html directory.
# mkdir /tmp/test
# mount -t iso9660 -o loop CentOS-7-x86_64.iso /tmp/test

# mkdir /data/www/html/centos7
# cp -r /tmp/test/* /data/www/html/centos7

# umount /tmp/test
# mount -t iso9660 -o loop CentOS-6.10-x86_64.iso /tmp/test

# mkdir /data/www/html/centos6
# cp -r /tmp/test/* /data/www/html/centos6

  • Start and enable nginx service and allow firewall rule.
# systemctl enable nginx
# systemctl start nginx
# firewall-cmd --add-port=80/tcp --permanent
# firewall-cmd --reload

Yum repository client configuration

  • Delete all existing repo files if needed.
# cd /etc/yum.repos.d/
# mkdir bkp
# mv *.repo bkp/

  • Create repo file in /etc/yum.repos.d for centos 7 operating system.
# vim local.repo
name=Local yum server

Test yum repository
# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: LocalRepo
Cleaning up list of fastest mirrors
Other repos take up 112 M of disk space (use --verbose for details)
# yum update all
Loaded plugins: fastestmirror
Determining fastest mirrors
LocalRepo                                                                                       | 3.6 kB  00:00:00     
(1/2): LocalRepo/group_gz                                                                       | 155 kB  00:00:00     
(2/2): LocalRepo/primary_db                                                                     | 5.3 MB  00:00:00     
No Match for argument: all
No package all available.
No packages marked for update
# yum info vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
Name        : vsftpd
Arch        : x86_64
Version     : 3.0.2
Release     : 25.el7
Size        : 353 k
Repo        : installed
From repo   : base
Summary     : Very Secure Ftp Daemon
URL         : https://security.appspot.com/vsftpd.html
License     : GPLv2 with exceptions
Description : vsftpd is a Very Secure FTP daemon. It was written completely from
            : scratch.
# yum install vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                  Arch                     Version                           Repository                   Size
 vsftpd                   x86_64                   3.0.2-10.el7                      LocalRepo                   167 k

Transaction Summary
Install  1 Package

Total download size: 167 k
Installed size: 347 k
Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.2-10.el7.x86_64.rpm                                                                  | 167 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : vsftpd-3.0.2-10.el7.x86_64                                                                          1/1 
  Verifying  : vsftpd-3.0.2-10.el7.x86_64                                                                          1/1 

  vsftpd.x86_64 0:3.0.2-10.el7                                                                                         

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                              repo name                                                   status
LocalRepo                                            Local yum server                                            3,723
repolist: 3,723

You May Also Like


About the Author: TekFik

TekFik is a technical blogging site helps techies and engineers to solve their day to day issues and also allows everyone to share knowledge and feedback. Please feel free to contact us at tekfik.rd@gmail.com if there is anything.

Leave a Reply

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