Difference between revisions of "Rocky9 Local Repo Server"

From Notes_Wiki
(Created page with "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: <code>/etc/yum.repos.d/rocky.repo</code> <pre> # 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 upda...")
 
 
(10 intermediate revisions by the same user not shown)
Line 5: Line 5:


== Enable Repositories ==
== Enable Repositories ==
Edit file: <code>/etc/yum.repos.d/rocky.repo</code>
Edit file: /etc/yum.repos.d/rocky.repo


<pre>
<pre>
Line 39: Line 39:
</pre>
</pre>


(Other sections like <code>debuginfo</code>, <code>source</code>, and <code>crb</code> can be left disabled.)
(Other sections like debuginfo , source and crb can be left disabled.)


== Enable RPM Caching ==
== Enable RPM Caching ==
Edit <code>/etc/dnf/dnf.conf</code> and add:
Edit /etc/dnf/dnf.conf and add:


<pre>
<pre>
Line 54: Line 54:
</pre>
</pre>


This ensures every installed package leaves a cached <code>.rpm</code> under:
This ensures every installed package leaves a cached .rpm under:


<code>/var/cache/dnf/&lt;repo-id&gt;-*/packages/</code>
/var/cache/dnf/&lt;repo-id&gt;-*/packages/


== Create Local Repo ==
== Create Local Repo ==
Line 62: Line 62:


<pre>
<pre>
sudo mkdir -p /var/www/html/dnf/localrepo
sudo mkdir -p /var/www/html/rocky9
sudo cp /var/cache/dnf/*/packages/*.rpm /var/www/html/dnf/localrepo/
sudo cp /var/cache/dnf/*/packages/*.rpm /var/www/html/rocky9
</pre>
</pre>


If Apache serves <code>/var/www/html/</code>, then symlink:
If Apache serves /var/www/html/, then symlink:


<pre>
<pre>
sudo ln -s /var/cache/dnf/ /var/www/html/rocky
sudo ln -s /var/cache/dnf/ /var/www/html/rocky9
</pre>
</pre>


Line 75: Line 75:


<pre>
<pre>
sudo createrepo /var/www/html/dnf/localrepo/
sudo createrepo /var/www/html/rocky9
</pre>
</pre>


== Fix Permissions ==
== Fix Permissions ==
<pre>
<pre>
sudo chown -R apache:apache /var/www/html/dnf/
sudo chown -R apache:apache /var/www/html/rocky9/
sudo chmod -R 755 /var/www/html/dnf/
sudo chmod -R 755 /var/www/html/rocky9/
sudo systemctl restart httpd
sudo systemctl restart httpd
</pre>
</pre>
Line 87: Line 87:
Now your repo is available at:
Now your repo is available at:


<code>http://172.30.14.58/dnf</code>
http://172.31.1.237/dnf


== Configure Client ==
== Configure Client ==
On the client machine, disable all other repos in <code>/etc/yum.repos.d/</code>.   
On the client machine, disable all other repos in /etc/yum.repos.d/.   
Create <code>/etc/yum.repos.d/local.repo</code>:
Create /etc/yum.repos.d/local.repo:


<pre>
<pre>
[local-repo]
[local-repo]
name=Local Repository
name=Local Repository
baseurl=http://172.30.14.58/dnf/localrepo/
baseurl=http://172.31.1.237/rocky9
enabled=1
enabled=1
gpgcheck=0
gpgcheck=0

Latest revision as of 07:11, 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/rocky9
sudo cp /var/cache/dnf/*/packages/*.rpm /var/www/html/rocky9

If Apache serves /var/www/html/, then symlink:

sudo ln -s /var/cache/dnf/ /var/www/html/rocky9

Generate repository metadata:

sudo createrepo /var/www/html/rocky9

Fix Permissions

sudo chown -R apache:apache /var/www/html/rocky9/
sudo chmod -R 755 /var/www/html/rocky9/
sudo systemctl restart httpd

Now your repo is available at:

http://172.31.1.237/dnf

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