apt-mirror
HowDownload doneccessary make a local debian apt mirror
To create a local Debian APT mirror, you can follow these general steps:
Set up a server: You will need a server with sufficient storage capacity and network bandwidth to host the mirror.
Install the necessary packages: Start by installing the apt-mirror package, which is available in the Debian repositories. Use the following command to install it:
sudo apt-getapt install apt-mirror dpkg-dev apache2
Configure
Edit the mirror: Open the apt-mirror configuration file using a text editor. The file is located atyour /etc/apt/mirror.list
. You can use the following command to open it with nano or vim:
sudo############# nanoconfig ##################
#
set base_path /etc/apt/mirror.listvar/spool/apt-mirror
set Insidemirror_path the$base_path/mirror
file,set youskel_path need$base_path/skel
toset definevar_path the$base_path/var
repositoriesset youcleanscript want$var_path/clean.sh
toset mirror.defaultarch Uncommentamd64 theset linesnthreads for20 theset desired_tilde repositories,0
or#
add############# newend linesconfig if##############
needed. For example:
deb http://deb.debian.org/debian busterbookworm main contrib non-free deb-srcnon-free-firmware
deb http://deb.debian.org/debian busterbookworm-updates main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main
clean http://deb.debian.org/debian
Save the file after making the necessary changes.
Configure the mirror directory: By default,
run apt-mirror uses the directory /var/spool/apt-mirror
to store the mirrored files. Ensure that you have enough space available in that directory, or specify a different location in the apt-mirror configuration file if needed.
Run apt-mirror: Execute the apt-mirror command with root privileges to start the mirroring process. Use the following command:
sudo apt-mirror
The mirroring process will take some time, depending on the speed of your network connection and the size of the repositories you're mirroring. Ensure that the server remains connected
Symlink to the internet during this process.
Serve the mirror using a web server: After the mirroring process completes, you need to serve the mirror using a web server. You can use any web server of your choice, such as Apache or Nginx. Install and configure the web server, ensuring that it points to the mirror directory you specified earlier.
Configure clients to use the local mirror: On the machines where you want to use the local mirror, modify the /etc/apt/sources.list file to point to your mirror's URL. Replace the original Debian repository URLs with the URL of your local mirror. For example:
debln http://your-mirror-url/debian buster main contrib non-free
deb-src http://your-mirror-url/debian buster main contrib non-free
Save the file after making the changes.
That'-s it! Your local Debian APT mirror should be ready to use. Clients can now update and install packages from the mirror, which will be significantly faster than downloading from the official Debian repositories. Remember to periodically update your mirror by running apt-mirror again to keep it synchronized with the official repositories.
Provide Apt-mirror via Apache2
Install Apache2: If you don't already have Apache2 installed, you can install it using the package manager. On Debian-based systems, you can use the following command:
sudo apt-get install apache2
Configure Apache2: Once Apache2 is installed, you need to configure it to serve your APT mirror. Open the Apache2 configuration file using a text editor. On Debian-based systems, the file is located at /etc/apache2/sites-available/000-default.conf. Use the following command to open it with nano or vim:
sudo nano /etc/apache2/sites-available/000-default.conf
Inside the file, you need to add a new Alias directive that maps a URL path to the directory where your mirror is located. For example, if your mirror is stored in /var/spool/apt-mirror, you can add the following line within the <VirtualHost> block:
Alias /debian /var/spool/apt-mirror/mirror/deb.debian.org/debian/ /var/www/html/debian
ln -s /var/spool/apt-mirror/mirror/security.debian.org/debian-security /var/www/html/debian-security
Save
Check the filecontents afterof making the changes.
Enable the Alias module: By default, the alias module is not enabled in Apache2. Enable it using the following command:
/var/www/html/debian
sudoroot@mirror:~# a2enmodls alias-l /var/www/html/
total 16
lrwxrwxrwx 1 root root 51 Jan 15 20:17 debian -> /var/spool/apt-mirror/mirror/deb.debian.org/debian/
lrwxrwxrwx 1 root root 65 Jan 15 20:32 debian-security -> /var/spool/apt-mirror/mirror/security.debian.org/debian-security/
Restart Apache2: After making
Create the configurationRepository changes, restart Apache2 for the changes to take effect:Metadata
sudocd service/var/www/html/debian apache2&& restartdpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
Test the mirror: Open
Create a webRelease browserFile
dpkg-scanpackages enter. the/dev/null URL> http://your-server-ip/debianRelease
(replace
Configure your server). You should see the directory listing of the Debian mirror, indicating that Apache2 is serving the mirror correctly.
Note: If you want to restrict access to the mirror and only allow specific clients to use it, you can configure Apache2 to add authentication or restrict access based on IP addresses.
With these steps, you have configured Apache2 to provide your local Debian APT mirror. Clients can now update their /etc/apt/sources.list
file
make sure you edit your ip address
deb http://192.168.178.101/debian bookworm main contrib non-free non-free-firmware
deb http://192.168.178.101/debian bookworm-updates main contrib non-free non-free-firmware
deb http://192.168.178.101/debian-security bookworm-security main
apt update
root@apt-mirror-client:~# tmux
-bash: tmux: command not found
root@apt-mirror-client:~# apt update
Hit:1 http://192.168.178.101/debian bookworm InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to pointdate.
root@apt-mirror-client:~# apt install tmux
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libevent-core-2.1-7 libutempter0
The following NEW packages will be installed:
libevent-core-2.1-7 libutempter0 tmux
0 upgraded, 3 newly installed, 0 to yourremove mirrorand URL,0 suchnot asupgraded.
Need to get 595 kB of archives.
After this operation, 1493 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://your-server-ip/192.168.178.101/debian, bookworm/main amd64 libevent-core-2.1-7 amd64 2.1.12-stable-8 [131 kB]
Get:2 http://192.168.178.101/debian bookworm/main amd64 libutempter0 amd64 1.2.1-3 [8960 B]
Get:3 http://192.168.178.101/debian bookworm/main amd64 tmux amd64 3.3a-3 [455 kB]
Fetched 595 kB in 0s (15.1 MB/s)
Selecting previously unselected package libevent-core-2.1-7:amd64.
(Reading database ... 21363 files and usedirectories itcurrently installed.)
Preparing to downloadunpack packages.../libevent-core-2.1-7_2.1.12-stable-8_amd64.deb from...
theUnpacking locallibevent-core-2.1-7:amd64 mirror.(2.1.12-stable-8) ...
Selecting previously unselected package libutempter0:amd64.
Preparing to unpack .../libutempter0_1.2.1-3_amd64.deb ...
Unpacking libutempter0:amd64 (1.2.1-3) ...
Selecting previously unselected package tmux.
Preparing to unpack .../archives/tmux_3.3a-3_amd64.deb ...
Unpacking tmux (3.3a-3) ...
Setting up libevent-core-2.1-7:amd64 (2.1.12-stable-8) ...
Setting up libutempter0:amd64 (1.2.1-3) ...
Setting up tmux (3.3a-3) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9+deb12u9) ...
root@apt-mirror-client:~#