[Linux] How to Create a Local Repository From a RPM File

  • OS Version: Redhat 7.5

Usually we will create a local repository for our intranet machines to use. So your mirror repository machine can connect to the internet, but sometimes we just want to create a offline repository to use what should we do?

Step1 Get RPM File & Install

Supposed you already have a local repository which is running by apache2 or nginx. Like the example below:

├── 3rdparty
│   ├── nginx
│   │   └── repodata

You can see we put single 3rdparty’s rpm to each folder. For example you can see nginx folder.

First you need to download the rpm file you want.

# Nginx http://nginx.org/packages/rhel/7Server/x86_64/RPMS/
# or  http://nginx.org/packages/mainline/rhel/7Server/x86_64/RPMS/

wget http://nginx.org/packages/mainline/rhel/7Server/x86_64/RPMS/nginx-1.17.4-1.el7.ngx.x86_64.rpm
mkdir /repo/mirror/3rdparty/nginx
mv nginx-1.17.4-1.el7.ngx.x86_64.rpm /repo/mirror/3rdparty/nginx
createrepo -v /repo/mirror/3rdparty/nginx
ll /repo/mirror/3rdparty/nginx

Then you will see your local repository have a new repository for nginx.


Step2 Create REPO file for the machine you need

# Command
vim /etc/yum.repos.d/nginx.repo

# Content
name=Nginx Local Repository

Now, you can install the package you need.

yum install nginx

That’s all.


Understanding Red Hat Content Delivery Network Repositories and their usage with Satellite 6

Add a Comment