个人工具

“UbuntuHelp:Apt-Cacher-Server”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第23行: 第23行:
  
 
Edit /etc/apt-cacher/apt-cacher.conf if you want to change any options.  The only one I changed was admin_email.
 
Edit /etc/apt-cacher/apt-cacher.conf if you want to change any options.  The only one I changed was admin_email.
 +
 +
Import any existing apt-get cache:
 +
sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
  
 
== Client Configuration ==
 
== Client Configuration ==
第37行: 第40行:
  
 
2. Use a proxy.
 
2. Use a proxy.
<If anyone knows how to make this work, please fill this section in.>
+
In a terminal, type:
 +
 
 +
<pre><nowiki>
 +
sudo nano /etc/apt/apt.conf.d/01proxy
 +
</nowiki></pre>
 +
 
 +
Inside your new file, add a line that says:
 +
 
 +
<pre><nowiki>
 +
Acquire::http::Proxy "http://<IP address or hostname of the apt-cacher server>:3142";
 +
</nowiki></pre>
 +
 
 +
/!\ Currently the 2nd method gives an error when upgrading to a newer release. You should use 1st method to get around this. See [https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/113658 bug 113658 in Launchpad]
 +
 
 +
=== Switching proxy settings ===
 +
If you are using a laptop as an apt-cacher client, you won't be able to connect to get any updates when you are away from your network.  The easiest way I know of to get around this requires using the proxy method, and editing the /etc/apt/apt.conf.d/01proxy file each time you are away from your network.  Add a line to your 01proxy file that says:
 +
 
 +
<pre><nowiki>
 +
Acquire::http::Proxy "http://";
 +
</nowiki></pre>
 +
 
 +
Apt will use whichever line is LAST, so if you are connected to your home network, put this line at the top of the file.  If you are connected to the internet elsewhere, just cut and paste (in nano, Ctrl+k is cut, and Ctrl+u is paste/uncut) this line so that it is at the bottom, and you will get the updates directly. Remember to switch it back when you are back at home, or you will not be using apt-cacher to cache your updates!
  
NEEDED:  How to configure a laptop so that it uses apt-cacher when connected to it's home network, and the regular repository when it's not.
+
There is likely a better/easier way of doing this, but I haven't found it. If you know the solution, please update this!
  
  

2007年11月22日 (四) 12:02的版本



Introduction

This page describes the installation and configuration of apt-cacher. It was drawn from http://www.debuntu.org/how-to-set-up-a-repository-cache-with-apt-cacher and Ubuntu Hacks by Oxer, Rankin, and Childers http://www.oreilly.com/catalog/ubuntuhks/

Server Installation

1. Install apt-cacher and apache2 webserver sudo apt-get install apt-cacher apache2

2. Enable apt-cacher Edit /etc/default/apt-cacher and change autostart to 1

Note: I had problems doing this on a machine with apache already installed.

Then test by going to http://server/apt-cacher to verify that it's running.

Server Configuration

Edit /etc/apt-cacher/apt-cacher.conf if you want to change any options. The only one I changed was admin_email.

Import any existing apt-get cache: sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives

Client Configuration

There are two ways to configure your clients to use apt-cacher.

1. Modify your sources.list In client /etc/apt/sources.list insert apt-cacher-server/apt-cacher/ in each line, ie deb http://archive.ubuntu.com/ubuntu/ dapper main restricted becomes deb http://apt-cacher-server/apt-cacher/archive.ubuntu.com/ubuntu/ dapper main restricted Then run apt-get update

2. Use a proxy. In a terminal, type:

sudo nano /etc/apt/apt.conf.d/01proxy

Inside your new file, add a line that says:

Acquire::http::Proxy "http://<IP address or hostname of the apt-cacher server>:3142";

/!\ Currently the 2nd method gives an error when upgrading to a newer release. You should use 1st method to get around this. See bug 113658 in Launchpad

Switching proxy settings

If you are using a laptop as an apt-cacher client, you won't be able to connect to get any updates when you are away from your network. The easiest way I know of to get around this requires using the proxy method, and editing the /etc/apt/apt.conf.d/01proxy file each time you are away from your network. Add a line to your 01proxy file that says:

Acquire::http::Proxy "http://";

Apt will use whichever line is LAST, so if you are connected to your home network, put this line at the top of the file. If you are connected to the internet elsewhere, just cut and paste (in nano, Ctrl+k is cut, and Ctrl+u is paste/uncut) this line so that it is at the bottom, and you will get the updates directly. Remember to switch it back when you are back at home, or you will not be using apt-cacher to cache your updates!

There is likely a better/easier way of doing this, but I haven't found it. If you know the solution, please update this!