• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How To Set up an Apt-Cache Server using Apt-Cacher-NG

1074

To Set up an ‘ Apt-Cache’ Server - ‘ Apt-Cacher-NG’ in Ubuntu 16.04 Server

Apt-Cacher-NG acts as caching server. It also acts as a proxy for clients in the local network to share the datas that has been downloaded in the server. ‘ Apt-Cache’ Server Using ‘ Apt-Cacher-NG’ set up is discussed in this tutorial.

Advantages

  • apt-cacher-ng will save our bandwidth
  • apt-cacher-ng will save our time.
  • We can integrate ISO image or DVD to apt-cacher-ng using import option.

Server Setup

Server OS : Ubuntu 16.04
Server IP Address : 192.168.5.212
Default Port : 3142

Client Setup

Client OS : Ubuntu 15.10
Client IP Address : 192.168.5.172

To Install and Configuring Apt-Cacher-NG on Server

Use the following command to install Apt-cacher-ng server.

root@linuxhelp:-# apt-get install apt-cacher-ng
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting ' apt-cacher-ng'  for glob ' apt-cacher-ng*' 
The following NEW packages will be installed:
  apt-cacher-ng
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 504 kB of archives.
.
.
. 
Setting up apt-cacher-ng (0.9.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...


Edit the configuration of apt-cacher-ng located in ‘ /etc/apt-cacher-ng‘

root@linuxhelp:-# vim /etc/apt-cacher-ng/acng.conf


Enable the CacheDir line. Since Installing or updating all dpkg package will be stored in this directory.
You can also change the location of Caching path.

CacheDir: /var/cache/apt-cacher-ng


For Log, enable the following line. By default it will be enabled automatically and this path can also be changed.

LogDir: /var/log/apt-cacher-ng


Here Port 3142 is used which is the default one. If you need to change you can.

Port:3142


‘ BindAddress: 0.0.0.0’ entry needs to be added in the configuration file.

# BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
BindAddress: 0.0.0.0


For the reports of apt-cache, enable the following line.

ReportPage: acng-report.html


Uncomment the below line for getting more information about ' log' .

VerboseLog: 1


By default PID file will be located in /var location. So just enable it by uncommenting the following line.

PidFile: /var/run/apt-cacher-ng/pid


Thus the configuration is completed. Now save and close the file. By using following command we need to restart apt-cacher-ng service.

root@linuxhelp:-# /etc/init.d/apt-cacher-ng restart
[ ok ] Restarting apt-cacher-ng (via systemctl): apt-cacher-ng.service.


Using the below URL access the report page of apt-cacher-ng:
http://192.168.5.212:3142
1

In this interface, hit on Statistics report and configuration page to view the transfer statistics.
statistics
2

Configuration of Client Side

At first create a file called ‘ 02proxy’ in ‘ /etc/apt/apt.conf.d/’ path.
Then copy the Acquire URL so that you will able to access report page in web interface.

root@linuxhelp:-# nano /etc/apt/apt.conf.d/02proxy
Acquire::http { Proxy " http://192.168.0.125:3142"   } 


Acquired URL is shown in the web interface.
3

Now save and exit that file. Repository needs to be updated and packages are to be upgraded.

root@linuxhelp:-# apt-get update
root@linuxhelp:-# apt-get upgrade


It will upgrade 89 packages and its size is 171 MB. It will take only few seconds to upgrade since all the packages are cached in apt-cached-ng server. Thus it helps in consuming internet as well as time. For Cache count data, we can access via web browser to see the statistics.
4

Tags:
liam
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What if i wanted to fetch the package from another mirror which isn’t in the sources.list file of APT? Will APT-cacher-ng will cache that package too?? If not, is it possible to configure ap

A

Yes, you can add any repository URL to sources.list moreover even you are allowed to use PPA repo, the same PPA repo need to be installed in all clients.

Q

why should I use this

A

the main purpose is to reduce Bandwidth

Q

i will need to run 2 instances of apt-cacher-ng, one for the 32bit, and the other instance for the 64bit version. The question is, how can I run two instances of apt-cacher-ng on the same m

A

You don't need two instances. The same service can serve both 32bit clients and 64bits clients. Also, the service can run be run on any architecture, i.e., the server can be either 32bits or

Q

What does APT cache do?

A

The apt-cache command line tool is used for searching apt software package cache. In simple words, this tool is used to search software packages, collects information of packages and also used to search for what available packages are ready for installation on Debian or Ubuntu based systems.

Q

How do I clear apt get cache?

A

You can run 'sudo apt-get clean' to clean out any cached .debs. If they're needed, they will be downloaded again. There's also a program called computer-janitor to help with removing old files. If you messed around with installing partial packages then "apt-get autoclean" removes them too.

Related Tutorials in How To Set up an Apt-Cache Server using Apt-Cacher-NG

Related Tutorials in How To Set up an Apt-Cache Server using Apt-Cacher-NG

How To Set up an Apt-Cache Server using Apt-Cacher-NG
How To Set up an Apt-Cache Server using Apt-Cacher-NG
Jun 6, 2016
How to Set up APT-Caching Server Using Apt-Cacher NG on Debian 11.3
How to Set up APT-Caching Server Using Apt-Cacher NG on Debian 11.3
Oct 28, 2022
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.