红联Linux门户
Linux帮助

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

发布时间:2015-12-31 10:32:08来源:linux网站作者:yuanchao99

需求:

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


通过HTTP代理访问SSH服务:http://www.linuxdiyf.com/linux/15595.html

git HTTP代理服务器配置:http://www.linuxdiyf.com/linux/15445.html

ubuntu下通过privoxy将Socks代理转换为Http代理:http://www.linuxdiyf.com/linux/13715.html