特殊:Badtitle/NS100:Apt-Cacher-Server/zh:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Seabee留言 | 贡献
Seabee留言 | 贡献
去掉英文,免得看起来很乱。
第10行: 第10行:


本页描述 apt-cacher 的安装和配置。本文是Oxer、Rankin和Childers 从 http://www.debuntu.org/how-to-set-up-a-repository-cache-with-apt-cacher 和 Ubuntu Hacks抽取出来的。http://www.oreilly.com/catalog/ubuntuhks/<br>
本页描述 apt-cacher 的安装和配置。本文是Oxer、Rankin和Childers 从 http://www.debuntu.org/how-to-set-up-a-repository-cache-with-apt-cacher 和 Ubuntu Hacks抽取出来的。http://www.oreilly.com/catalog/ubuntuhks/<br>
================<br>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/


== 安装服务  ==
== 安装服务  ==

2010年1月17日 (日) 12:25的版本


{{#ifexist: :Apt-Cacher-Server/zh/zh | | {{#ifexist: Apt-Cacher-Server/zh/zh | | {{#ifeq: {{#titleparts:Apt-Cacher-Server/zh|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Apt-Cacher-Server/zh|1|-1|}} | zh | | }}



介绍

本页描述 apt-cacher 的安装和配置。本文是Oxer、Rankin和Childers 从 http://www.debuntu.org/how-to-set-up-a-repository-cache-with-apt-cacher 和 Ubuntu Hacks抽取出来的。http://www.oreilly.com/catalog/ubuntuhks/

安装服务

1. 安装 apt-cacher and apache2 网络服务

编辑 /etc/default/apt-cacher ,将自动启动改为 1 注意: 我在已经安装了apache的机器上出现了问题。
然后同过访问 http://server/apt-cacher 进行测试,验证设置是否起作用。


================
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.

服务的配置

如果你想要更改任何选项,请编辑 /etc/apt-cacher/apt-cacher.conf。我只改变了 admin_email。导入任何现有的 apt-get 缓存:

sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives 


=============
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

客户端的配置

有两种方法配置你的客户端去使用apt-cacher。

编辑你的 sources.list

在客户端 /etc/apt/sources.list 中每行都插入 apt-cacher-server/apt-cacher/,例如 将 deb http://archive.ubuntu.com/ubuntu/ dapper main restricted 改成 deb http://apt-cacher-server/apt-cacher/archive.ubuntu.com/ubuntu/ dapper main restricted
(提醒: 建议在 apt-cacher的页面 也加入 ‘:3142’-这造成了系统的失败对我来说) 然后运行
apt-get udpate;

使用代理


在终端输入:

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


在你的新文件中加入以下行:
Acquire::http::Proxy "http://<IP address or hostname of the apt-cacher server>:3142";
/!\ 这个第二种方式会在升级到新版本的时候出现错误。你因该使用第一种方式来解决这个问题。 在 Launchpad 查看 bug 113658


================
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 (Warning: The apt-cacher web page advises to also add ':3142' - this caused the system to fail for me) 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

更换代理设置

如果你使用笔记本电脑作为apt-cacher的客户端,你不能在你连接不到网络的时候去连接并更新。我所知道的最简单的解决方法就是需要使用代理的方式。然后在你连接不到网络的时候随时编辑 /etc/apt/apt.conf.d/01proxy 这个文件。在你的 01proxy文件中加入:

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

apt无论如何都会使用最后的一行,所以如果你是连接到你的(home network)自己的网络,把该行放到文件的最顶端。如果你要在其他地方连接到互联网,只要剪切并粘贴该行到文件的最底端,然后你就可以直接更新了。记住在你回家后要更换设置,不然你将不能使用 apt-cacher 去缓存你的更新!这似乎是一个比较好或者比较简单的方法,但我重没成功过。如果你知道解决方法,请更新本文。


================
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!