Project

General

Profile

Support #198

Updated by Daniel Curtis about 9 years ago

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 
 <pre> 
 sudo apt-get install apt-cacher-ng 
 </pre> 

 Once the package is finished installing, open a web browser and go to http://apt.example.com/ http://aptcacherIP/ 
 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"; "http://aptcacherIP: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 http://aptcacherIP:3142/ftp.debian.org/debian stable main contrib non-free* 
 > *deb-src http://apt.example.com:3142/ftp.debian.org/debian http://aptcacherIP: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 http://aptcacherIP: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@: 
 <pre> 
 > deb http://apt.example.com:3142/ftp.debian.org/debian http://aptcacherIP:3142/ftp.debian.org/debian stable main contrib non-free 
 </pre> 

 * Then refresh the repository information of the client: 
 <pre> 
 sudo apt-get update 
 </pre> 

 h2. Importing existing package archive 

 * If there are already packages installed on the client, they can be copied into apt-cacher-ng by: 
 <pre> 
 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 
 </pre> 
 And then open the web configuration and go to the *Statistics report and configuration page*, then click *[Start Import]* [Start Import] 

Back