Project

General

Profile

Support #198

Installing apt-cacher-ng on Debian

Added by Daniel Curtis over 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Automated Server Management
Target version:
-
Start date:
09/16/2013
Due date:
% Done:

100%

Estimated time:
1.50 h
Spent time:

Description

During the expansion of the ALT VPS Infrastructure, I needed a place to store and cache packages for the servers in the ALT DMZ network. This would increase overall performance by caching updates and installed packages on the APT caching server and serving them to the local nodes in the ALT DMZ network. Creating new virtual servers will also see a boost in speed, since bootstrapping a newly created virtual server will pull from the APT caching server instead of having to download the packages from the Internet.

  • Install apt-cacher-ng on the caching server
    sudo apt-get install apt-cacher-ng
    

Once the package is finished installing, open a web browser and go to http://apt.example.com/
This will bring you to a page displaying:

You attempted to browse the contents of a virtual HTTP repository. However, the intended way of use is the configuration of APT and related package management systems to retrieve the software packages through this service.

To configure APT for use of Apt-Cacher NG you need to...

EITHER: Configure APT to use a HTTP proxy by specifying it in apt.conf or related configuration files, see apt.conf manual page for details. Server and Port need to match the values used to visit this page. For example, edit /etc/apt/apt.conf and add the line:

Acquire::http { Proxy "http://apt.example.com:3142"; };

OR: Edit the /etc/apt/sources.list file and edit the source lines therein, replacing the mirror hostname with the hostname of this server machine and the port with 3142 (adding a port if none specified). For example:

deb http://ftp.debian.org/debian stable main contrib non-free
deb-src http://ftp.debian.org/debian stable main contrib non-free

becomes:

deb http://apt.example.com:3142/ftp.debian.org/debian stable main contrib non-free
deb-src http://apt.example.com:3142/ftp.debian.org/debian stable main contrib non-free

Depending on the configuration, it might be possible to use a shortcut for the base URLs without knowing the mirror, for example:

deb http://apt.example.com:3142/debian stable main contrib non-free

Ask your system administrator for details.

  • This means the installation succeeded and hosts can now be pointed to the APT caching server by adding the following to the clients /etc/apt/sources.list:
    deb http://apt.example.com:3142/ftp.debian.org/debian stable main contrib non-free
    
  • Then refresh the repository information of the client:
    sudo apt-get update
    

Importing existing package archive

  • If there are already packages installed on the client, they can be copied into apt-cacher-ng by:
    sudo mkdir /var/cache/apt-cacher-ng/_import
    sudo cp /var/cache/apt/archives/* /var/cache/apt-cacher-ng/_import/
    sudo chown -R apt-cacher-ng /var/cache/apt-cacher-ng/_import
    

    And then open the web configuration and go to the Statistics report and configuration page, then click [Start Import]
#1

Updated by Daniel Curtis about 9 years ago

  • Description updated (diff)
#2

Updated by Daniel Curtis about 9 years ago

  • Project changed from 46 to GNU/Linux Administration
  • Category set to Automated Server Management

Also available in: Atom PDF