Support > About independent server > Process for setting up the local Yum/DNF repository on CentOS 8
Process for setting up the local Yum/DNF repository on CentOS 8
Time : 2024-12-04 15:17:58
Edit : Jtti

Configuring a local Yum/DNF repository on CentOS 8 helps you manage software packages in environments where you do not have an Internet connection or need to control software package versions. Let's complete setting up the local Yum/DNF repository on CentOS 8.

Ensure that you have a CentOS 8 system with sufficient disk space and storage packages. Start by installing tools for creating and managing local storage:

sudo dnf install -y createrepo yum-utils

Create another directory to hold the local repository:

sudo mkdir -p /var/www/html/localrepo

Download the required software package from the CentOS 8 image or other sources, such as using the reposync command to synchronize the software package from the official repository:

sudo reposync --repo=baseos --repo=appstream --repo=extras --download-path=/var/www/html/localrepo

The above command can download the package from the official repository to the /var/www/html/localrepo directory.

Just like creating a repository element, use the createrepo command to generate metadata in the repository directory:

sudo createrepo /var/www/html/localrepo

Create a new.repo file to configure the local repository:

sudo tee /etc/yum.repos.d/localrepo.repo <<EOF

[localrepo]

name=Local Repository

baseurl=file:///var/www/html/localrepo

enabled=1

gpgcheck=0

EOF

Verify the local repository, clear the cache, and regenerate the cache to ensure that the local repository is configured correctly:

sudo dnf clean all

sudo dnf makecache

Try installing a package from the local repository again to verify the configuration:

sudo dnf install <package_name>

If you want to access the local repository over HTTP, you can configure a simple HTTP server, such as using the Apache HTTP server. To install the Apache HTTP server:

sudo dnf install -y httpd

To configure the Apache HTTP server, create a symbolic link to make the repository directory accessible via HTTP:

sudo ln -s /var/www/html/localrepo /var/www/html/repo

Modify the Apache configuration file, / etc/HTTPD/conf/HTTPD. Conf, ensure that contains the following contents:

<Directory "/var/www/html/repo">

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

Start and enable the Apache HTTP server:

sudo systemctl start httpd

sudo systemctl enable httpd

Configuration DNF using HTTP access local repository, modify the/etc/yum repos. D/localrepo. Repo file, change the baseurl URL for HTTP:

[localrepo]

name=Local Repository

baseurl=http://<your_server_ip>/repo

enabled=1

gpgcheck=0

Clear the cache and regenerate the cache, then try to install the package to make sure the configuration is correct:

sudo dnf clean all

sudo dnf makecache

sudo dnf install <package_name>

By performing the preceding steps to configure the local Yum/DNF repository, you can manage software packages offline in the CentOS8 system. You can access the repository directly through a file system or configure an HTTP server to provide remote access. Using a local repository gives you better control over package versions and dependencies to suit different usage scenarios.

Relevant contents

How do I increase the number of disk inodes in Linux A way to find the geographic location of a Linux server in a terminal Common methods for viewing all installed software packages in CentOS What are the common commands for diagnosing Linux hard disk problems The role of virtual file systems in Linux Useful RPM package management commands in Linux Quick Linux Method of viewing installed software packages Common operations on Linux disk partitioning tool Parted What is the network resilience of Hong Kong servers and how to maintain it Useful tool for monitoring CPU and GPU temperature in Ubuntu
Go back

24/7/365 support.We work when you work

Support