准备:docker镜像debian:latest
运行docker:
docker run -it -w /home/debian_source/mirror -w /home/debian_source/skel -w /home/debian_source/var -v /opt/debian_source:/home/debian_source -p 0.0.0.0:6868:80 --name debianMirror debian:latest
第一步、安装apt-mirror工具
apt-get install -y vim apache2 apt-mirror
第二步、配置apt-mirror,修改/etc/apt/mirror.list
set base_path /home/debian_source
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 <running host architecture>
set nthreads 3 #可以设置为小一点数字为3,防止网络拥挤
deb-i386 http://ftp.us.debian.org/debian jessie main contrib non-free
deb-amd64 http://ftp.us.debian.org/debian jessie main contrib non-free
deb-i386 http://security.debian.org/ jessie/updates main contrib non-free
deb-amd64 http://security.debian.org/ jessie/updates main contrib non-free
clean http://ftp.us.debian.org/debian
clean http://security.debian.org/
第三步、同步镜像
# apt-mirror
等待几个小时,大概90G左右。期间直接退出终端,不要关闭docker容器,如果想再次进入使用:
docker exec -it 容器ID /bin/bash
第四步、http访问镜像-服务器镜像设置
修改apatch2的配置文件/etc/apache2/sites-enabled/000-default,把DocumentRoot /var/www改为:
DocumentRoot /home/debian_source/mirror/ftp.us.debian.org/debian
然后重启apache:
/etc/init.d/apache2 restart
第五步、client访问设置:
修改sources.list
vim /etc/apt/sources.list
添加:
deb http://服务器ip地址 jessie main contrib non-free