How to Build Your Own Local Yum and Apt Repositories on Linux
This guide explains step‑by‑step how to create local package repositories for RPM‑based (yum/dnf) and Debian‑based (apt) Linux systems, covering required tools, directory setup, metadata generation, repository configuration files, and example commands for easy deployment.
Creating a Yum/DNF Repository (RPM‑based Distributions)
RPM‑based Linux distributions use yum (or the newer dnf) to manage packages. To set up a local repository you need to install createrepo, create a directory for the RPM files, generate repository metadata, and write a .repo configuration file.
Install createrepo sudo yum install createrepo Create a repository directory mkdir /opt/rpms Copy RPM packages into the directory
Generate repository metadata createrepo /opt/rpms Run the command again with --update when you add new packages.
Create the repository configuration file The file must reside in /etc/yum.repos.d/ and have a .repo extension. Essential options include:
Repository ID (e.g., [customrepo])
Name (e.g., name=CustomRepository)
Baseurl (e.g., baseurl=file:///opt/rpms)
Enabled (e.g., enabled=1)
Gpgcheck (e.g., gpgcheck=0)
[customrepo]
name=CustomRepository
baseurl=file:///opt/rpms
enabled=1
gpgcheck=0Creating an APT Repository (Debian‑based Systems)
Debian‑based systems use apt utilities to manage packages. To build a local APT repository, install the development tools, create a directory for .deb files, generate a package index, and add the repository to sources.list.
Install dpkg‑dev sudo apt-get install dpkg-dev Create a repository directory mkdir /opt/debs Place .deb packages into the directory
Generate the package index
cd /opt/debs
dpkg-scanpackages . /dev/null > ReleaseThis creates a Release file that apt can read.
Add the repository to sources.list deb file:///opt/debs ./ If the packages are unsigned, you can bypass GPG checks with: deb [trusted=yes] file:///opt/debs ./ Building a local repository is useful for providing customized packages, reducing bandwidth on multiple machines, or testing packages before public release.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
