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