使用apt-mirror搭建debian镜像源

简介: debian官方提供了脚本ftpsync来搭建源镜像,而 apt-mirror 是一个更简单便捷的源镜像搭建工具。 安装 apt-mirror sudo apt-get install apt-mirror 配置文件/etc/apt/mirror.list只要修改很少的地方,大部分使用默认值即可。

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社区”。
相关文章
|
8月前
|
Ubuntu
Ubuntu 安装使用yum
Ubuntu 安装使用yum
1205 0
debian11换源
直接编辑 /etc/apt/sources.list 文件
886 0
|
Linux
yum镜像源汇总
yum镜像源汇总
3079 0
|
5月前
RockyLinux/almalinux设置 dnf / yum 国内镜像
RockyLinux/almalinux设置 dnf / yum 国内镜像
513 0
|
Ubuntu 应用服务中间件 nginx
apt-mirror搭建Ubuntu镜像站
因为公司要经常用到Ubuntu,又没有镜像站,使用外面的镜像站虽说很方便,但是速度有点慢,只能自己折腾一个镜像站了。 apt-mirror在网上教程很多,但是很乱,一些地方就直接省略。 似乎tunasync比较方便,在部署完apt-mirror之后才看到有这个,公司不给服务器我折腾了,没办法
1381 0
apt-mirror搭建Ubuntu镜像站
|
Ubuntu 开发工具 Perl
Ubuntu的一些软件源
Ubuntu的一些软件源
141 0
|
Linux Ubuntu
|
Ubuntu Apache 安全
使用 APT-mirror 四步配置 Ubuntu 本地软件仓库
使用 APT-mirror 四步配置 Ubuntu 本地软件仓库 今天,我们将向你展示如何在你的 Ubuntu 个人电脑或 Ubuntu 服务器中,直接通过 Ubuntu 官方软件仓库来配置本地软件仓库。
2426 0