Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Create an Apt Repository Mirror with apt-mirror ====== The goal of this guide is to set up a local Debian package mirror using the ''%%apt-mirror%%'' tool and Apache to serve the files. ===== Install apt-mirror ===== The version of ''%%apt-mirror%%'' that is included in the Debian repositories is old and broken, so we need to use a forked version that is not broken. [[https://github.com/Stifler6996/apt-mirror|Stifler6996 on GitHub provides a non-broken version]] that we will use today. So first we will install Git to clone the repository: <code>apt install -y git</code> Then we will find a suitable spot to install apt-mirror, clone the repository, and then symlink it to ''%%/usr/local/bin%%'' so it's easy to call: <code> cd /usr/local/src git clone https://github.com/Stifler6996/apt-mirror ln -s /usr/local/src/apt-mirror/apt-mirror /usr/local/bin </code> ===== Configuring apt-mirror ===== Now we need to set up apt-mirror to download our repositories. Before continuing, make sure you have a sizeable disk mounted somewhere on this system to store the downloaded repositories. For the sake of this demo I'm assuming you have a disk mounted at ''%%/srv/repos%%'', but if you want them stored elsewhere then just change that path to match your config. Thankfully apt-mirror is easy to configure. It's basically just creating ''%%/etc/apt/mirror.list%%'' with the sources entries you want and some options telling apt-mirror how to behave. Below is an example that will copy the major Debian repositories: <code> ############# config ################## # set base_path /var/spool/apt-mirror # set mirror_path /opt/repos/ubuntu # 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 ############## # Debian 11 (Bullseye) ... repos ... clean ... </code> ===== Install Apache ===== Install Apache: <code>apt install -y apache2</code> wiki/linux/setup_apt_mirror.txt Last modified: 2023/04/28 13:43by Greg