I have four computers running Ubuntu, two 9.10 servers, and two desktops running 9.04. Last night, both of my servers needed 50Mb of updates, and I wondered, why bother downloading two different sets for both of them? Which is when I stumbled onto Apt-Cacher, which is basically a caching proxy server for Apt, and exactly what I wanted. With the help of this post on Ubuntu Forums, I set up my main server to act as a proxy for the rest of the computers in the house. And here, is how its done :)
Install apt-cacher with
sudo apt-get install apt-cacher apache2
apache2 is installed so that you can see some stats on Apt-Cacher if you go to the proxy’s IP and port 3142, I’ll explain that later.
Ok, now to get the proxy running at boot, edit your services file
sudo nano /etc/services
and add the following to the bottom
apt-cacher 3142/tcp apt-cacher 3142/udp
3142 is the default port, and there’s probably no need to change it. Exit nano with Ctrl+X and press Y to save. Finally edit this
sudo nano /etc/default/apt-cacher<
and set AUTOSTART to 1. Thats it, apt-cacher will now run at startup, so now either reboot or use
sudo /etc/init.d/apt-cacher restart
to get running straight away.
At this stage, you may want to change a few of the default options, so open up apt-cacher’s config file with
sudo nano /etc/apt-cacher/apt-cacher.conf
The only two things here that I’m going to explain are the two I needed to change cache_dir and admin_email. I changed from the default location, which is on my very small / drive, to my larger drive mounted as /home. Also, I changed admin_email really just to be correct, its not essential.
Next thing to do to ease along the transition is to add all the packages your server has already download to the cache, you don’t want to leave all that go to waste like. To do that, run the following,
sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives
You now have a fully functinal, fully loaded apt-cacher server. But whos going to connect to it? You need to set the server as a proxy for apt and Synaptic for the clients. To do so, run
echo 'Acquire::http::Proxy "http://hostname:3142";' | sudo tee /etc/apt/apt.conf.d/01proxy
replacing hostname with the hostname or IP of your server. You should also use this on your server, replacing hostname with localhost. That way, any packages your server downloads will be added to the cache and available to the clients.
To set the proxy in Syanptic open up Synaptic (System > Administration > Synaptic) then select Settings > Preferences. Select the Network tab, select Manual Proxy Configuration and enter the hostname or IP of your server, and the port, 3142. Click Apply and Ok and your done.
Thats it, you’ve set up your own Apt-Cacher server. See the post mentioned at the top for a few other details, including a roaming mode for laptop users.
Just a note, this server can be used for different releases, mine is working for both Jaunty and Karmic. However, if you download a package on your Karmic Server and then attempt to download it on your Jaunty client, the Jaunty client will need to download the package again. This is because they use different repositories. Its probably the exact same, but it treats it as being different, and rightly so.
Here’s hoping that this is clear and useful. Leave a comment if you’ve questions :)
Filed under: HowTo, Operating Systems, Posts, Server, Ubuntu | 10 Comments
Tags: Apt, Apt-Cacher, HowTo, Proxy, Server, Synaptic, Ubuntu
AMD64 Apt Apt-Cacher Apt-Cacher-NG Arch ArchBang Artic Silver 5 Backups Bang86 Broadband Celeron CentOS Cleaning Clonezilla Compiz Conky copy recursively CPU Crunchbang Debian DPKG Ebay find Firefox Flash Gnome GRUB GTk Hardware Heatsink HowTo Jesred Karmic Laptop Linux LUbuntu Maverick Network New Computer NTFS Nvidia Office 2007 Openbox Operating Systems Packages Packard Bell Pentium Pentium IV Perlico PIII postaweek2011 Posts Proxy RAID Repairs RSync Sensors Server Size Mismatch Snow Squid SSH Synaptic System64 Tecra terminal commands Themes Ubuntu Upgrade USB VNC W2K3 Windows Wine Xubuntu 9.10
- HOWTO: Repair a broken Ext4 Superblock in Ubuntu
- HOWTO: Fix an NTFS partition in Ubuntu
- HOWTO: Mount Partitions in Terminal - FSTab
- HOWTO: Start VirtualBox VM on boot - Windows
- HOWTO: Disable Suspend and Hibernate – Ubuntu
- HOWTO: StartX automatically on Login - Ubuntu
- HOWTO: Completely Remove ubuntu-desktop
- HOWTO: Allow SSH logins from Anywhere
- HOWTO: Apt-Cacher-NG on Ubuntu
- HOWTO: Ubuntu UPnP Server to XBox 360 using uShare
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.