如何在有http代理的局域网内建立ubuntu源镜像

需求:

 在局域网内建立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




 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值