个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{Copyedit translation}} {{From|https://help.ubuntu.com/community/Apt-Cacher-Server}} {{Translator| tlhl28 }} {{Languages|UbuntuHelp:Apt-Cacher-Server}} == <br>介绍 == 本页...)
 
配置客户端
 
(未显示2个用户的8个中间版本)
第1行: 第1行:
{{Copyedit translation}}
+
{{From|https://help.ubuntu.com/community/Apt-Cacher-Server}}
 
+
{{From|https://help.ubuntu.com/community/Apt-Cacher-Server}}  
+
 
+
 
{{Translator| tlhl28 }}  
 
{{Translator| tlhl28 }}  
 +
{{Languages|UbuntuHelp:Apt-Cacher-Server}}
 +
== 介绍 ==
 +
本页描述 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>''pablodav 注明: 在 Jaunty 及以后新的版本,我推荐使用这个缓存代替类似 apt-proxy 的其他缓存。
 +
== 安装服务 ==
 +
1. 安装apt-cacher和apache2
  
{{Languages|UbuntuHelp:Apt-Cacher-Server}}
+
sudo apt-get install apt-cacher apache2
 
+
2. 启用apt-cacher
== <br>介绍  ==
+
 
+
本页描述 apt-cache 的安装和配置。本文是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/
+
 
+
== 安装服务  ==
+
 
+
1. 安装 apt-cacher and apache2 网络服务
+
 
+
编辑 /etc/default/apt-cacher ,将自动启动改为 1 注意: 我在已经安装了apache的机器上出现了问题。<br>然后同过访问 http://server/apt-cacher 进行测试,验证设置是否起作用。
+
 
+
<br>
+
 
+
================<br>Server Installation<br>1. Install apt-cacher and apache2 webserver
+
<pre>sudo apt-get install apt-cacher apache2 2. Enable apt-cacher
+
</pre>
+
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 缓存:
+
<pre>sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
+
</pre>
+
<br>=============<br>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。<br>
+
 
+
=== 编辑你的 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<br>(提醒: 建议在 apt-cacher的页面 也加入 ‘:3142’-这造成了系统的失败对我来说) 然后运行 <br>apt-get udpate;
+
 
+
=== 使用代理  ===
+
 
+
<br>在终端输入:
+
<pre>sudo nano /etc/apt/apt.conf.d/01proxy
+
</pre>
+
<br>在你的新文件中加入以下行:<br>Acquire::http::Proxy "http://&lt;IP address or hostname of the apt-cacher server&gt;:3142";<br>/!\ 这个第二种方式会在升级到新版本的时候出现错误。你因该使用第一种方式来解决这个问题。 [https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/113658 在 Launchpad 查看 bug 113658]<br>
+
 
+
 
+
 
+
================<br>Client Configuration
+
 
+
There are two ways to configure your clients to use apt-cacher.<br>1. Modify your sources.list<br>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 <br>2. Use a proxy.<br>In a terminal, type:<br>sudo nano /etc/apt/apt.conf.d/01proxy<br>Inside your new file, add a line that says:<br>Acquire::http::Proxy "http://&lt;IP address or hostname of the apt-cacher server&gt;:3142";<br>/!\ 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文件中加入:
+
<pre>Acquire::http::Proxy "http://";
+
</pre>
+
apt无论如何都会使用最后的一行,所以如果你是连接到你的(home network)自己的网络,把该行放到文件的最顶端。如果你要在其他地方连接到互联网,只要剪切并粘贴该行到文件的最底端,然后你就可以直接更新了。记住在你回家后要更换设置,不然你将不能使用 apt-cacher 去缓存你的更新!这似乎是一个比较好或者比较简单的方法,但我重没成功过。如果你知道解决方法,请更新本文。<br>
+
 
+
  
 +
编辑 /etc/default/apt-cacher,把autostart改成 1
 +
<br>注意: 我在已经安装了apache的机器上出现了问题。
 +
<br>''JT 注明: 如果已经安装了apache,要重启apache:''  <code><nowiki>sudo invoke-rc.d apache2 restart</nowiki></code>
 +
<br>''pablodav 附注: 我建议也要重启apt-cacher: <code><nowiki>sudo invoke-rc.d apt-cacher restart</nowiki></code>
 +
可以验证一下 http://server/apt-cacher 有没有在运行。
 +
<br>''pablodav 注明: 在 Jaunty中 需要把 http://server/apt-cacher 替换成 http://server:3142 (看起来像不再使用 /apt-cacher了).
  
================<br>Switching proxy settings
+
== 配置服务 ==
 +
如果你想要改变选项,请编辑 /etc/apt-cacher/apt-cacher.conf。我只改变 admin_email。
 +
导入已存在的 apt-get 缓存:
 +
sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
 +
<br>''pablodav 附注: 我强烈推荐对于符号链接使用 -d 选项。在 Jaunty 中,我需使用 sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives
 +
=== 在服务器上的CD加载包 ===
 +
在升级期间,当你的缓存使用 CD 镜像,你会发现它比使用更新服务器快。
 +
首先,下载你选择的 CD 镜像(我推荐使用 bit-torrent)。
 +
其次,在运行 apt-cacher 的服务器上加载 CD 镜像:
 +
<pre><nowiki>
 +
sudo mount -o loop /home/username_or_other_path/ubuntu-9.10-rc-alternate-i386.iso /media/cdrom0
 +
</nowiki></pre>
 +
第三,导入 CD 镜像,你需要用 -R 去获取 CD 的目录结构,-r 则是复制包到缓存而不是去建立连接:
 +
<pre><nowiki>
 +
sudo /usr/share/apt-cacher/apt-cacher-import.pl -R -r /media/cdrom0
 +
</nowiki></pre>
 +
你可以看见脚本显示正在导入大量包。 
 +
== 配置客户端 ==
 +
有两种方法配置你的客户端去使用apt-cacher。
 +
<br>''pablodav 注明: 我不推荐改变第一步里面的每一行。在 Jaunty 中 /apt-cacher 不会成功。请跳到第二步。
 +
<br>1. 更改你的 sources.list
  
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:  
+
在客户端的 /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' - 这对我来说造成了系统的出错)
 +
<br>''JT & Comet 注明: 在 gutsy 和 hardy, 我用'' <code><nowiki>server/apt-cacher/</nowiki></code> ''不能正常运行,但是用'' <code><nowiki>server:3142/</nowiki></code> ''(NB: 没有 /apt-cacher/) 可以运行得很好。''
 +
<br>''澄清,应使用:'' <code><nowiki>deb http://apt-cacher-server:3142/archive.ubuntu.com/ubuntu/ hardy main restricted</nowiki></code>
 +
<br>''Scientus 说明: 我认为这是因为 apt-cacher 它自己的 http 服务器而这里是用 apache''
 +
接着运行
 +
apt-get update
 +
<br>2. 使用代理。
  
Acquire::http::Proxy "http://";  
+
在终端输入:
 +
<pre><nowiki>
 +
sudo nano /etc/apt/apt.conf.d/01proxy
 +
</nowiki></pre>
 +
在你的新文件里添加一行:
 +
<pre><nowiki>
 +
Acquire::http::Proxy "http://<IP address or hostname of the apt-cacher server>:3142";
 +
</nowiki></pre>
 +
=== 切换代理设置 ===
 +
如果你使用笔记本电脑作为 apt-cacher 的客户端,当你要在连接不到你的网络的时候去连接并更新。我所知道的最简单的解决方法就是需要使用代理的方式。然后当你连接不到你的网络的时候随时编辑 /etc/apt/apt.conf.d/01proxy 这个文件。在你的 01proxy 文件中加入:
 +
<pre><nowiki>
 +
Acquire::http::Proxy "http://";
 +
</nowiki></pre>
 +
Apt无论如何都会使用最后的一行,所以如果是连接到你的家庭网络,把该行放到文件的最顶端。如果你要在其他地方连接到互联网,只要剪切并粘贴该行到文件的最底端(在 nano 中, 剪切是 Ctrl+k ,粘帖是 Ctrl+u ),然后你就可以直接更新了。记住在你回家后要更换设置,不然你将不能使用 apt-cacher 去缓存你的更新!
 +
这似乎是一个比较好或者比较简单的方法,但我重没成功过。如果你知道解决方法,请更新本文。
 +
----
 +
[[category:CategoryPackageManagement]]
  
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!<br><br>
+
[[category:UbuntuHelp]]

2010年4月5日 (一) 14:04的最新版本

介绍

本页描述 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/
pablodav 注明: 在 Jaunty 及以后新的版本,我推荐使用这个缓存代替类似 apt-proxy 的其他缓存。

安装服务

1. 安装apt-cacher和apache2

sudo apt-get install apt-cacher apache2 2. 启用apt-cacher

编辑 /etc/default/apt-cacher,把autostart改成 1
注意: 我在已经安装了apache的机器上出现了问题。
JT 注明: 如果已经安装了apache,要重启apache: sudo invoke-rc.d apache2 restart
pablodav 附注: 我建议也要重启apt-cacher: sudo invoke-rc.d apt-cacher restart 可以验证一下 http://server/apt-cacher 有没有在运行。
pablodav 注明: 在 Jaunty中 需要把 http://server/apt-cacher 替换成 http://server:3142 (看起来像不再使用 /apt-cacher了).

配置服务

如果你想要改变选项,请编辑 /etc/apt-cacher/apt-cacher.conf。我只改变 admin_email。 导入已存在的 apt-get 缓存: sudo /usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
pablodav 附注: 我强烈推荐对于符号链接使用 -d 选项。在 Jaunty 中,我需使用 sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives

在服务器上的CD加载包

在升级期间,当你的缓存使用 CD 镜像,你会发现它比使用更新服务器快。 首先,下载你选择的 CD 镜像(我推荐使用 bit-torrent)。 其次,在运行 apt-cacher 的服务器上加载 CD 镜像:

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

第三,导入 CD 镜像,你需要用 -R 去获取 CD 的目录结构,-r 则是复制包到缓存而不是去建立连接:

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

你可以看见脚本显示正在导入大量包。

配置客户端

有两种方法配置你的客户端去使用apt-cacher。
pablodav 注明: 我不推荐改变第一步里面的每一行。在 Jaunty 中 /apt-cacher 不会成功。请跳到第二步。
1. 更改你的 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' - 这对我来说造成了系统的出错)
JT & Comet 注明: 在 gutsy 和 hardy, 我用 server/apt-cacher/ 不能正常运行,但是用 server:3142/ (NB: 没有 /apt-cacher/) 可以运行得很好。
澄清,应使用: deb http://apt-cacher-server:3142/archive.ubuntu.com/ubuntu/ hardy main restricted
Scientus 说明: 我认为这是因为 apt-cacher 它自己的 http 服务器而这里是用 apache 接着运行 apt-get update
2. 使用代理。

在终端输入:

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

在你的新文件里添加一行:

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

切换代理设置

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

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

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