个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
第3行: 第3行:
 
== Introduction ==
 
== 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/
 
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/
 +
''Added by pablodav:In Newer installations like Jaunty I recommend use this cacher instead others like apt-proxy.
 
== Server Installation ==
 
== Server Installation ==
 
1. Install apt-cacher and apache2 webserver
 
1. Install apt-cacher and apache2 webserver
第12行: 第13行:
 
Note: I had problems doing this on a machine with apache already installed.
 
Note: I had problems doing this on a machine with apache already installed.
 
''Added by JT: Restart apache if you already had it installed:''  <code><nowiki>sudo invoke-rc.d apache2 restart</nowiki></code>
 
''Added by JT: Restart apache if you already had it installed:''  <code><nowiki>sudo invoke-rc.d apache2 restart</nowiki></code>
 +
''Added by pablodav: I suggest to restart apt-cacher also: <code><nowiki>sudo invoke-rc.d apt-cacher restart</nowiki></code>
 
Then test by going to http://server/apt-cacher to verify that it's running.
 
Then test by going to http://server/apt-cacher to verify that it's running.
 +
''Added by pablodav: In Jaunty use http://server:3142 instead http://server/apt-cacher (this seems to be not working anymore with /apt-cacher).
 
== Server Configuration ==
 
== Server Configuration ==
 
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:
 
Import any existing apt-get cache:
 
sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
 
sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
 +
''Added by pablodav: I strongly recommend to use -d option for symlinks, In Jaunty I had to use sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives
 +
=== Load Packages on Server from CD ===
 +
Around upgrade time, you may find it useful to get the CD image instead of using the slow update servers, and populate your cache using that. 
 +
First, download your CD image(s) of choice (I'd recommend using bit-torrent).
 +
Second, mount the CD image on the server running apt-cacher :
 +
<pre><nowiki>
 +
sudo mount -o loop /home/username_or_other_path/ubuntu-9.10-rc-alternate-i386.iso /media/cdrom0
 +
</nowiki></pre>
 +
Third, run the import on the CD image, you need the -R is needed to recurse into the CD directory structure, the -r just makes sure they are copied to the cache instead of trying to link:
 +
<pre><nowiki>
 +
sudo /usr/share/apt-cacher/apt-cacher-import.pl -R -r /media/cdrom0
 +
</nowiki></pre>
 +
You should see the script saying that it is importing a lot of packages. 
 
== Client Configuration ==
 
== Client Configuration ==
 
There are two ways to configure your clients to use apt-cacher.
 
There are two ways to configure your clients to use apt-cacher.
 +
''Added by pablodav: I don't recommend to change every line with step 1. In Jaunty /apt-cache does not works. Jump to step 2 for Client Configuration.
 
1. Modify your sources.list
 
1. Modify your sources.list
  

2009年11月17日 (二) 18:31的版本


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/ Added by pablodav:In Newer installations like Jaunty I recommend use this cacher instead others like apt-proxy.

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. Added by JT: Restart apache if you already had it installed: sudo invoke-rc.d apache2 restart Added by pablodav: I suggest to restart apt-cacher also: sudo invoke-rc.d apt-cacher restart Then test by going to http://server/apt-cacher to verify that it's running. Added by pablodav: In Jaunty use http://server:3142 instead http://server/apt-cacher (this seems to be not working anymore with /apt-cacher).

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 Added by pablodav: I strongly recommend to use -d option for symlinks, In Jaunty I had to use sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives

Load Packages on Server from CD

Around upgrade time, you may find it useful to get the CD image instead of using the slow update servers, and populate your cache using that. First, download your CD image(s) of choice (I'd recommend using bit-torrent). Second, mount the CD image on the server running apt-cacher :

sudo mount -o loop /home/username_or_other_path/ubuntu-9.10-rc-alternate-i386.iso /media/cdrom0

Third, run the import on the CD image, you need the -R is needed to recurse into the CD directory structure, the -r just makes sure they are copied to the cache instead of trying to link:

sudo /usr/share/apt-cacher/apt-cacher-import.pl -R -r /media/cdrom0

You should see the script saying that it is importing a lot of packages.

Client Configuration

There are two ways to configure your clients to use apt-cacher. Added by pablodav: I don't recommend to change every line with step 1. In Jaunty /apt-cache does not works. Jump to step 2 for Client Configuration. 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 (Warning: The apt-cacher web page advises to also add ':3142' - this caused the system to fail for me) Added by JT: on gutsy and hardy, I could not get this to work with server/apt-cacher/ but server:3142/ (NB: without the /apt-cacher/) worked fine. To clarify, use eg. deb http://apt-cacher-server:3142/archive.ubuntu.com/ubuntu/ hardy main restricted Scientus: I think this is because apt-cacher is its own http server and this setup use apache 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";

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!