Ubuntu 16.04搭建本地mirror软件源(含16和14):html
参考网址(感谢做者):http://blog.csdn.net/fanwanli04/article/details/79622726nginx
注:
一、该操做仅同步了amd64的软件,没作i386软件的同步
二、16.04软件须要空间140G,14.04软件须要空间116Gapache
修改16.04 mirror配置:ubuntu
############# config ##################
#
set base_path /space/mirror/16.04
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 amd64
set postmirror_script $var_path/postmirror.sh
set run_postmirror 0ide
set nthreads 20
set _tilde 0
#
############# end config ##############post
deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverseui
clean http://archive.ubuntu.com/ubuntuspa
:wq.net
开始同步:rest
若是想一直保持更新,能够作个计划任务定时执行
Ubuntu 14.04基本同上,将/etc/apt/mirror.list.14.04写为trusty
安装apache2
<VirtualHost *:8080> (默认为80)
DocumentRoot /space/mirror (默认为/var/www/html)
:wq
Listen 8080
:wq
<Directory /space/mirror/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
:wq
访问:http://ip:8080 (先确保apache能够正常访问)
安装nginx:
upstream apt-mirror {
server 127.0.0.1:8080;
}
server {
root /space/mirror;
...... location /ubuntu/14.04/ { proxy_pass http://apt-mirror/14.04/mirror/archive.ubuntu.com/ubuntu/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; } location /ubuntu/16.04/ { proxy_pass http://apt-mirror/16.04/mirror/archive.ubuntu.com/ubuntu/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; }
}
:wq
http {
...... client_header_buffer_size 512k; large_client_header_buffers 4 512k; client_max_body_size 100m;
}
:wq
访问:http://ip/ubuntu/16.04 (确保能正常访问)
客户端设置:
deb [arch=amd64] http://10.0.1.5/ubuntu/16.04 xenial main restricted
deb [arch=amd64] http://10.0.1.5/ubuntu/16.04 xenial-updates main restricted
deb [arch=amd64] http://10.0.1.5/ubuntu/16.04 xenial universe
:wq