How to Setup Local APT Repository Server On Ubuntu 24.04 Using apt-mirror
Dec 2, 2025
In today’s video, I will walk you through **how to set up a Local APT Repository Server on Ubuntu 24.04** using `apt-mirror`.
If you manage multiple Ubuntu systems, creating a local APT mirror helps you:
✔ Download packages once and share across many machines
✔ Speed up updates and installations
✔ Save internet bandwidth
✔ Run updates in offline or isolated networks
---
## 🧰 **Prerequisites**
* Ubuntu 24.04 server
* At least **800GB** free space under `/var`
* Stable internet connection
👉 All commands and files used in this tutorial are shared below.
---
## 🛠️ **Steps Covered in This Tutorial**
### **1️⃣ Install Required Packages**
sudo apt install apt-mirror apache2 -y
### **2️⃣ Configure `apt-mirror`**
Edit the configuration file:
sudo vi /etc/apt/mirror.list
Customize parameters:
* `defaultarch amd64`
* `nthreads 20`
* Add/remove `deb-src` based on storage availability
* Mirror only necessary components (main, universe, multiverse, restricted)
---
############# config ##################
#
set base_path /var/spool/apt-mirror
#
set mirror_path $base_path/mirror
set skel_path $base_path/skel
set var_path $base_path/var
set cleanscript $var_path/clean.sh
set defaultarch amd64
set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu noble-security main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu noble-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble-security main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu
clean http://security.ubuntu.com/ubuntu
---
### **3️⃣ Start Mirroring Ubuntu Repositories**
Begin downloading all packages & metadata:
sudo apt-mirror
Recommended (runs even if session disconnects):
nohup sudo apt-mirror &
tail -f nohup.out
---
### **4️⃣ Serve the Mirror Using Apache**
Create symbolic links:
sudo ln -s /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu /var/www/html/ubuntu
sudo ln -s /var/spool/apt-mirror/mirror/security.ubuntu.com/ubuntu /var/www/html/ubuntu-security
Restart Apache:
sudo systemctl restart apache2
Test the mirror:
http://SERVER-IP/ubuntu/dists/noble/
---
### **5️⃣ Automate Repository Sync with Cron**
sudo crontab -e
Add daily sync at 2 AM:
0 2 * * * /usr/bin/apt-mirror | tee /var/log/apt-mirror.log
---
### **6️⃣ Configure Client Machines**
Edit: /etc/apt/sources.list.d/ubuntu.sources
Add your local repo URL, then update:
sudo apt update
sudo apt install net-tools -y
Your client machines will now pull packages directly from the local mirror.
---
If this tutorial helped you:
👍 Like the video
💬 Comment your questions
🔔 Subscribe for more Linux & DevOps tutorials
Thanks for watching — see you in the next one! 🚀
---
Show More Show Less 