需求:
在局域网内建立ubuntu 12.04的源镜像服务器,服务器只能通过http proxy访问外网。
假定:
把所有源文件放到/var/www/mirror/ubuntu/precise目录下
步骤:
1. 安装apt-mirror
$sudo apt-get install apt-mirror
2. 在/var/www/mirror/ubuntu/precise目录下建立三个目录:
$cd /var/www/mirror/ubuntu/precise
$mkdir mirror skel var
3.修改mirror.list配置文件:
$sudo vim /etc/apt/mirror.list
原始文件内容:
# set base_path /var/spool/apt-mirror
#
# if you change the base path you must create the directories below with write privlages
#
# 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 base_path /var/www/mirror/ubuntu/precise
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 nthreads 20
set _tilde 0
再修改一下文件中的源路径如下:
deb-amd64 http://mirrors.yun-idc.com/ubuntu precise main restricted universe multiverse
deb-amd64 http://mirrors.yun-idc.com/ubuntu precise-security main restricted universe multiverse
deb-amd64 http://mirrors.yun-idc.com/ubuntu precise-updates main restricted universe multiverse
deb-amd64 http://mirrors.yun-idc.com/ubuntu precise-proposed main restricted universe multiverse
deb-amd64 http://mirrors.yun-idc.com/ubuntu precise-backports main restricted universe multiverse
deb-i386 http://mirrors.yun-idc.com/ubuntu precise main restricted universe multiverse
deb-i386 http://mirrors.yun-idc.com/ubuntu precise-security main restricted universe multiverse
deb-i386 http://mirrors.yun-idc.com/ubuntu precise-updates main restricted universe multiverse
deb-i386 http://mirrors.yun-idc.com/ubuntu precise-proposed main restricted universe multiverse
deb-i386 http://mirrors.yun-idc.com/ubuntu precise-backports main restricted universe multiverse
deb-src http://mirrors.yun-idc.com/ubuntu precise main restricted universe multiverse
deb-src http://mirrors.yun-idc.com/ubuntu precise-security main restricted universe multiverse
deb-src http://mirrors.yun-idc.com/ubuntu precise-updates main restricted universe multiverse
deb-src http://mirrors.yun-idc.com/ubuntu precise-proposed main restricted universe multiverse
deb-src http://mirrors.yun-idc.com/ubuntu precise-backports main restricted universe multiverse
clean http://hk.archive.ubuntu.com/ubuntu
4.修改wget的配置文件(注意:如果内网只能通过http proxy上网,则这一步必须进行)
$sudo vim /etc/wgetrc,修改其中的http_proxy, https_proxy和ftp_proxy三个配置项。
5.创建postmirror.sh文件
$touch /var/www/mirror/ubuntu/precise/var/postmirror.sh
6.执行同步操作:
$sudo apt-mirror