Setup Local YUM Repository Server on Rocky Linux 8.6 for Offline Package Management
Learn how to set up a local YUM repository server in Rocky Linux 8.6 using an ISO image, configure a client machine to access the repository over HTTP, and simplify package management in a disconnected environment. Follow along as I demonstrate step-by-step instructions for creating a reliable, self-sustained repository solution
Server Details:
- Server IP: 192.168.100.10
- Hostname: yumserver.galaxycloud.in
- YUM Config File Location: /etc/yum.repos.d/
Client Details:
- Client IP: 192.168.100.11
- Hostname: webserver.galaxycloud.in
- YUM Config File Location: /etc/yum.repos.d/
To resolve the server name on the client machine, you can add the following entry to the /etc/hosts
file:echo "192.168.100.10 yumserver.galaxycloud.in" >> /etc/hosts
On the Server Machine (yumserver.galaxycloud.in):
List Current YUM Repositories: Run the following command to list all currently enabled repositories:dnf repolist
Copy or Download the Rocky Linux 8.6 ISO to the Server:
You can use WinSCP
or scp
to copy the ISO file to the server.Make sure the ISO is copied to /linux-iso/Rocky-8.6-x86_64-dvd1.iso
on the server.
Create Necessary Directories:
Create the directory to host the mounted ISO:mkdir -p /var/www/html/iso/rocky8/
Backup existing YUM repository configuration files:mkdir /backup
cd /etc/yum.repos.d/
mv Rocky-* /backup/.
Mount the ISO: Mount the ISO to the /var/www/html/iso/rocky8/
directory:
mount -o loop /linux-iso/Rocky-8.6-x86_64-dvd1.iso /var/www/html/iso/rocky8/
Permanently Mount the ISO using /etc/fstab
: To ensure the ISO mounts automatically on reboot, add this entry to /etc/fstab
:/linux-iso/Rocky-8.6-x86_64-dvd1.iso /var/www/html/iso/rocky8 iso9660 loop,defaults 0 0
Create the Local YUM Repository Configuration: Create a new YUM repository file:
vim /etc/yum.repos.d/Rocky8-Local.repo
#Add the following configuration for the local repository:[Rocky8.6-AppStream]
name=Rocky 8.6 Local AppStream Repo
baseurl=file:///var/www/html/iso/rocky8/AppStream/
enabled=1
gpgcheck=0
[Rocky8.6-BaseOS]
name=Rocky 8.6 Local BaseOS Repo
baseurl=file:///var/www/html/iso/rocky8/BaseOS/
enabled=1
gpgcheck=0
Clear the Cache & List Repositories: Clean the YUM cache and verify that the new local repositories are available:dnf clean all
dnf repolist
Install Apache HTTP Server: To serve the YUM repository over HTTP, install the Apache web server:dnf install httpd
Start and Enable HTTP Service: After installation, start and enable the Apache service to ensure it runs on boot:systemctl restart httpd
systemctl enable httpd
This will allow your YUM repository to be accessible via HTTP for your client machines. You can now move to the next step of configuring the client machine to use this repository.
On the Client Machine (webserver.galaxycloud.in):
Create the YUM Client Repo File: Open or create the YUM repository file on the client machine:
vim /etc/yum.repos.d/Rocky8-Client.repo
#Add the Following Repository Configuration:[Rocky8.6-AppStream]
name=Rocky 8.6 Local AppStream Repo
baseurl=http://yumserver.galaxycloud.in/iso/rocky8/AppStream/
enabled=1
gpgcheck=0
[Rocky8.6-BaseOS]
name=Rocky 8.6 Local BaseOS Repo
baseurl=http://yumserver.galaxycloud.in/iso/rocky8/BaseOS/
enabled=1
gpgcheck=0
Clear Cache and List Repositories: Run the following commands to clean the YUM cache and list available repositories:dnf clean all
dnf repolist
Install Packages from the Local Repository: To verify the setup, try installing a package such as httpd:dnf install httpd
Congratulations! You have successfully set up a local YUM repository server on Rocky Linux 8.6 and configured a client machine to access it. This setup is ideal for managing packages in a closed or offline environment, ensuring efficient and reliable software management. If you encounter any issues or have further questions, feel free to leave a comment. Happy learning and keep exploring the endless possibilities of Linux!