How To Cache Apt Packages On A Network Using Apt-Cacher

If you’ve got more than one computer running Debian that packages are downloaded through apt, then apt-cacher should help you a lot.

Apt-cacher is actually a cgi script that is run by apache. Using apt-cacher is very easy, and installing it is even easier.

Step 1: Install apt-cacher.
(Run this on the proxy computer)

apt-get install apt-cacher

Enter the webpage : http://localhost/apt-cacher
to see that the proxy is running.

Step 2: Backup and Convert Clients sources.list.
(Do this on the computers that you want to access the cache.)

cp /etc/apt/sources.list /etc/apt/sources.list.backup

vi /etc/apt/sources.list

Press ‘:’ while in vi.

Enter “%s/http:///http://[Your Proxy IP]/apt-cacher?//g

This searches through your sources and adds http://[Your Proxy IP]/apt-cacher?/ before every repository.

An example from my sources.list looks like this:

deb sarge-backports main

Step 3: Update Clients

apt-get update

Optional Step 4: Import Existing packages into the apt-cacher cache

Copy the desired packages to the proxy directory /var/cache/apt-cacher/import

Run the import script to make it so that apt-cacher can use them.
perl /usr/share/apt-cacher/

Step 5: Use apt-get

If the required previous steps completed successfully you should now be able to use apt with it’s connection proxied through your apt-cacher proxy.

Questions / Comments, leave me a comment, and I’ll reply.

Jon Howe

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2020