Difference between revisions of "Ubuntu Local Repo Server Setup"

From Notes_Wiki
 
Line 3: Line 3:




= Ubuntu Local Repo Server Setup (Server = 172.30.14.59) =
= Ubuntu Local Repo Server Setup =


== Keep Downloaded Packages ==
== Keep Downloaded Packages ==
Line 65: Line 65:


<pre>
<pre>
http://172.30.14.59/apt
http://172.31.1.238/apt
</pre>
</pre>


Line 84: Line 84:


<pre>
<pre>
deb [trusted=yes] http://172.30.14.59/apt ./
deb [trusted=yes] http://172.31.1.238/apt ./
</pre>
</pre>



Latest revision as of 07:45, 22 September 2025

Home > Ubuntu > Ubuntu Local Repo Server Setup


Ubuntu Local Repo Server Setup

Keep Downloaded Packages

By default, Ubuntu removes downloaded .deb files from /var/cache/apt/archives/ after a successful install. To keep them permanently:

sudo nano /etc/apt/apt.conf.d/02keep-debs

Add the following line:

APT::Keep-Downloaded-Packages "true";

Save and exit. Now all downloaded packages will stay in /var/cache/apt/archives/.

Install Apache

sudo apt update
sudo apt install apache2 -y
sudo systemctl enable apache2
systemctl status apache2

Create Repository Directory

sudo mkdir -p /var/www/html/apt
sudo chmod -R 755 /var/www/html/apt

Copy Cached Packages

Move cached .deb files into the repository directory:

sudo cp /var/cache/apt/archives/*.deb /var/www/html/apt/

Generate APT Metadata

Install dpkg-dev:

sudo apt install dpkg-dev -y

Generate Packages.gz index:

cd /var/www/html/apt
sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Now the repo contains:

  • .deb files
  • Packages.gz (index file)

Verify Apache

Check if the repository is served:

http://172.31.1.238/apt

Also confirm locally:

ls -lh /var/www/html/apt/Packages.gz

Configure Client

On the client machine, edit sources:

sudo nano /etc/apt/sources.list

Add:

deb [trusted=yes] http://172.31.1.238/apt ./

Remove conflicting files:

sudo rm -rf /etc/apt/sources.list.d/*.sources
sudo rm -rf /var/lib/apt/lists/

Test from Client

sudo apt-get clean
sudo apt-get update

Install Package from Repo

sudo apt-get install package-name


Home > Ubuntu > Ubuntu Local Repo Server Setup