使用apt-mirror搭建debian镜像源

debian官方提供了脚本ftpsync来搭建源镜像,而 apt-mirror 是一个更简单便捷的源镜像搭建工具。

安装 apt-mirror

sudo apt-get install apt-mirror

配置文件/etc/apt/mirror.list只要修改很少的地方,大部分使用默认值即可。

这里使用中科大镜像 ftp.cn.debian.org 作为上游镜像,只镜像 debian jessie amd64 架构,不镜像源代码包。

############# config ##################
#
# set base_path    /var/spool/apt-mirror
#
# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch   # 默认架构与镜像主机的架构一致,这里是amd64
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############
 
deb http://ftp.cn.debian.org/debian jessie main contrib non-free
deb http://ftp.cn.debian.org/debian/ jessie-backports main contrib non-free
deb http://ftp.cn.debian.org/debian/ jessie-proposed-updates main contrib non-free
deb http://ftp.cn.debian.org/debian/ jessie-updates main contrib non-free
deb http://ftp.cn.debian.org/debian-security/ jessie/updates main contrib non-free
#deb-src http://ftp.us.debian.org/debian unstable main contrib non-free
 
# mirror additional architectures
#deb-alpha http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-amd64 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-armel http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-hppa http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-i386 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-ia64 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-m68k http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-mips http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-mipsel http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-powerpc http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-s390 http://ftp.us.debian.org/debian unstable main contrib non-free
#deb-sparc http://ftp.us.debian.org/debian unstable main contrib non-free
 
clean http://ftp.cn.debian.org/debian

开启自动同步

只需 root 权限 cron 自动运行 apt-mirror 命令即可。

# m h  dom mon dow   command
0 0 * * * apt-mirror

发布镜像服务

使用nginx发布源镜像

将 apt-mirror 的镜像目录链接到/var/www/mirror

# ln -sf /var/spool/apt-mirror/mirror/ftp.cn.debian.org/ mirror

然后将nginx默认主机default(或者单独虚拟主机)的根目录设置为/var/www/mirror,并开启目录列表

root /var/www/mirror
location / {
    autoindex on;
}

其他机器就可以正常使用新建的源镜像了。


原文发布时间: 2016-12-28
本文来自云栖社区合作伙伴“ Debian社区”,了解相关信息可以关注“ Debian社区”。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值