Difference between revisions of "Rocky9 Local Repo Server"
From Notes_Wiki
| Line 96: | Line 96: | ||
[local-repo] | [local-repo] | ||
name=Local Repository | name=Local Repository | ||
baseurl=http://172.31.1.237/ | baseurl=http://172.31.1.237/rocky9 | ||
enabled=1 | enabled=1 | ||
gpgcheck=0 | gpgcheck=0 | ||
Revision as of 07:08, 11 October 2025
Home > Rocky Linux or CentOS > Rocky Linux 9.x > Rocky9 Local Repo Server
Rocky9 Local Repo Server Setup (Server = 172.30.14.58)
Enable Repositories
Edit file: /etc/yum.repos.d/rocky.repo
# rocky.repo # # The mirrorlist system uses the connecting IP address of the client and the # update status of each mirror to pick current mirrors that are geographically # close to the client. You should use this for Rocky updates unless you are # manually picking other mirrors. # # If the mirrorlist does not work for you, you can try the commented out # baseurl line instead. [baseos] name=Rocky Linux $releasever - BaseOS mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS> #baseurl=http://dl.rockylinux.org/$contentdir/$releasever/BaseOS/$basearch/os/ gpgcheck=1 enabled=1 countme=1 metadata_expire=6h gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9 [appstream] name=Rocky Linux $releasever - AppStream mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=AppStr> #baseurl=http://dl.rockylinux.org/$contentdir/$releasever/AppStream/$basearch/o> gpgcheck=1 enabled=1 countme=1 metadata_expire=6h gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
(Other sections like debuginfo , source and crb can be left disabled.)
Enable RPM Caching
Edit /etc/dnf/dnf.conf and add:
[main] gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=True best=True skip_if_unavailable=False keepcache=1
This ensures every installed package leaves a cached .rpm under:
/var/cache/dnf/<repo-id>-*/packages/
Create Local Repo
Copy cached RPMs to your repo directory:
sudo mkdir -p /var/www/html/dnf/localrepo sudo cp /var/cache/dnf/*/packages/*.rpm /var/www/html/dnf/localrepo/
If Apache serves /var/www/html/, then symlink:
sudo ln -s /var/cache/dnf/ /var/www/html/rocky
Generate repository metadata:
sudo createrepo /var/www/html/dnf/localrepo/
Fix Permissions
sudo chown -R apache:apache /var/www/html/dnf/ sudo chmod -R 755 /var/www/html/dnf/ sudo systemctl restart httpd
Now your repo is available at:
Configure Client
On the client machine, disable all other repos in /etc/yum.repos.d/. Create /etc/yum.repos.d/local.repo:
[local-repo] name=Local Repository baseurl=http://172.31.1.237/rocky9 enabled=1 gpgcheck=0
Test on Client
sudo dnf clean all sudo dnf makecache sudo dnf install package-name
Home > Rocky Linux or CentOS > Rocky Linux 9.x > Rocky9 Local Repo Server