debian搭建本地镜像源

1、安装apt-mirror

  1. apt install apt-mirror

2、配置mirror.list

vim /etc/apt/mirror.list

  1. ############# config ##################
  2. #
  3. # set base_path /var/spool/apt-mirror
  4. #
  5. # set mirror_path $base_path/mirror
  6. # set skel_path $base_path/skel
  7. # set var_path $base_path/var
  8. # set cleanscript $var_path/clean.sh
  9. # set defaultarch <running host architecture>
  10. # set postmirror_script $var_path/postmirror.sh
  11. # set run_postmirror 0
  12. set nthreads 20
  13. set _tilde 0
  14. #
  15. ############# end config ##############
  16. #deb http://ftp.us.debian.org/debian unstable main contrib non-free
  17. #deb-src http://ftp.us.debian.org/debian unstable main contrib non-free
  18. #需要同步的debian源
  19. deb http://mirrors.aliyun.com/debian stable main contrib non-free
  20. deb http://mirrors.aliyun.com/debian stable-proposed-updates main contrib non-free
  21. deb http://mirrors.aliyun.com/debian stable-updates main contrib non-free
  22. #deb-src http://mirrors.aliyun.com/debian stable main contrib non-free
  23. #deb-src http://mirrors.aliyun.com/debian stable-proposed-updates main contrib non-free
  24. #deb-src http://mirrors.aliyun.com/debian stable-updates main contrib non-free
  25. # mirror additional architectures
  26. #deb-alpha http://ftp.us.debian.org/debian unstable main contrib non-free
  27. #deb-amd64 http://ftp.us.debian.org/debian unstable main contrib non-free
  28. #deb-armel http://ftp.us.debian.org/debian unstable main contrib non-free
  29. #deb-hppa http://ftp.us.debian.org/debian unstable main contrib non-free
  30. #deb-i386 http://ftp.us.debian.org/debian unstable main contrib non-free
  31. #deb-ia64 http://ftp.us.debian.org/debian unstable main contrib non-free
  32. #deb-m68k http://ftp.us.debian.org/debian unstable main contrib non-free
  33. #deb-mips http://ftp.us.debian.org/debian unstable main contrib non-free
  34. #deb-mipsel http://ftp.us.debian.org/debian unstable main contrib non-free
  35. #deb-powerpc http://ftp.us.debian.org/debian unstable main contrib non-free
  36. #deb-s390 http://ftp.us.debian.org/debian unstable main contrib non-free
  37. #deb-sparc http://ftp.us.debian.org/debian unstable main contrib non-free
  38. clean http://ftp.us.debian.org/debian

3、同步软件包

  1. apt-mirror

4、发布到web服务

4.1 安装apache服务器

apt-``get`` install apache2

如果使用的centos系统,执行yum install httpd

4.2 链接

ln -s /``var``/spool/apt-mirror/mirrormirrors.aliyun.com/debian /``var``/www/html/debian

OK,至此apt-mirror服务器搭建完成。

5、使用

切换至测试机器
vim /etc/apt/sources.list

  1. deb http://localhost/debian stable main contrib non-free
  2. deb http://localhost/debian stable-proposed-updates main contrib non-free
  3. deb http://localhost/debian stable-updates main contrib non-free

apt update
apt install vim