“UbuntuHelp:Apt-Cacher-Server/zh”的版本间的差异
来自Ubuntu中文
小 (去掉英文,免得看起来很乱。) |
(增加和修正翻译,去掉英文部分,免得看起来很乱。) |
||
第1行: | 第1行: | ||
− | + | {{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/ 。 | ||
+ | ''pablodav 注明: 在 Jaunty 及以后新的版本,我推荐使用这个缓存代替类似 apt-proxy 的其他缓存。 | ||
+ | == 安装服务 == | ||
+ | 1. 安装apt-cacher和apache2 | ||
− | + | sudo apt-get install apt-cacher apache2 | |
− | + | 2. 启用apt-cacher | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | 2. | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | 编辑 /etc/default/apt-cacher,把autostart改成 1 | |
+ | 注意: 我在已经安装了apache的机器上出现了问题。 | ||
+ | ''JT 注明: 如果已经安装了apache,要重启apache:'' <code><nowiki>sudo invoke-rc.d apache2 restart</nowiki></code> | ||
+ | ''pablodav 附注: 我建议也要重启apt-cacher: <code><nowiki>sudo invoke-rc.d apt-cacher restart</nowiki></code> | ||
+ | 可以验证一下 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 镜像: | ||
+ | <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。 | ||
+ | ''pablodav 注明: 我不推荐改变第一步里面的每一行。在 Jaunty 中 /apt-cache 不会成功。请跳到第二步。 | ||
+ | 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 和 karmic, 我用'' <code><nowiki>server/apt-cacher/</nowiki></code> ''不能正常运行,但是用'' <code><nowiki>server:3142/</nowiki></code> ''(NB: without the /apt-cacher/) 可以运行得很好。'' | ||
+ | ''澄清,应使用:'' <code><nowiki>deb http://apt-cacher-server:3142/archive.ubuntu.com/ubuntu/ hardy main restricted</nowiki></code> | ||
+ | ''Scientus 说明: 我认为这是因为 apt-cacher 它自己的 http 服务器而这里是用 apache'' | ||
+ | 接着运行 | ||
+ | apt-get update | ||
+ | 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]] | ||
− | + | [[category:UbuntuHelp]] |
2010年1月17日 (日) 13:28的版本
点击翻译: |
English • 中文 |
介绍
本页描述 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-cache 不会成功。请跳到第二步。 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 和 karmic, 我用 server/apt-cacher/
不能正常运行,但是用 server:3142/
(NB: without the /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 去缓存你的更新! 这似乎是一个比较好或者比较简单的方法,但我重没成功过。如果你知道解决方法,请更新本文。