apt-mirror建立本地ubuntu私有源
首先,我們要安裝apt-mirror
$sudo apt-get install apt-mirror
假設(shè)我們將鏡像等文件放在 /service/ubuntu文件夾下:
請事先新建以下文件夾(mirror.list里面提示要我們事先新建文件夾的):
/service/ubuntu
/service/ubuntu/mirror
/service/ubuntu/skel
/service/ubuntu/var
配置apt-mirror:
$sudo vi /etc/apt/mirror.list
--------------------------------------------------------------
############# config ##################
#
# 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>
#我們添加或更改如下內(nèi)容:
set base_path /service/ubuntu
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
#
############# end config ##############
#我們把常用的軟件同步過來就夠用了
deb-i386 http://archive.Ubuntu.com/ubuntu hardy main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-updates main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-security main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu hardy-proposed main restricted universe multiverse
#當(dāng)某些軟件包在服務(wù)器端進(jìn)行了升級,或者服務(wù)器端不再需要這些軟件包時,我們使用了 apt-mirror與服務(wù)器同步后,會在本地的$var_path/下生成一個clean.sh的腳本,列出了遺留在本地的舊版本和無用的軟件包,你可 以手動運(yùn)行這個腳本來刪除遺留在本地的且不需要用的軟件包
clean http://archive.ubuntu.com/ubuntu
-----------------------------------------------------------------------------
如果用amd64位架構(gòu)下的包,可以加上deb-amd64的標(biāo)記
如果什么都不加,直接使用deb http.....這種格式,則在同步時,只同步當(dāng)前系統(tǒng)所使用的架構(gòu)下的軟件包。比如一個64位系統(tǒng),直接debhttp....只同步64位的軟件 包。如果還嫌麻煩,直接去改set defaultarch?? <running hostarchitecture>這個參數(shù)就好,比如改成set defaultarch i386,這樣你使用debhttp.....這種格式,則在同步時,只同步i386的軟件包了。
如果你還想要源碼,可以把源碼也加到mirror.list里面同步過來,比如加上deb-src這樣的標(biāo)記。想要其他的東西也可以追加相應(yīng)的標(biāo)記來完成。
配置好后我們就可以和指定的鏡像進(jìn)行同步了
$sudo apt-mirror
如果是第一次同步,官方鏡像可能需要幾天時間才能同步完整,如果與國內(nèi)源進(jìn)行同步,只同步常用軟件,平均1秒鐘網(wǎng)速1MB(Byte)要同步30G左右的數(shù)據(jù),大概需要5-8小時的時間才能同步完整。
同步完成后,我們可以利用clean.sh清理無用軟件包(本文檔以set base_path /server/ubuntu為例):
$sudo sh /service/ubuntu/var/clean.sh
更新完畢后,可以使用apache發(fā)布源鏡像了。
以上摘錄 我下載了68個G的 64位源 同步的是mirrors.163.com
下面配置apache2
進(jìn)入httpd.conf修改
#<Directory />
#??? AllowOverride none
#??? Require all denied
#</Directory>
改成
<Directory />
??? Options FollowSymLinks
??? AllowOverride None
??? Order deny,allow
??? allow from all
</Directory>
在<IfModule alias_module> 節(jié)點中增加虛擬目錄
<IfModule alias_module>
??? Alias /ubuntu /workspace/ubuntu/mirror/mirrors.163.com/ubuntu
</IfModule>
添加虛擬目錄的權(quán)限
<Directory "/workspace/ubuntu/mirror/mirrors.163.com/ubuntu">
?????? Options Indexes FollowSymLinks
?????? AllowOverride None
??????? Require all granted
</Directory>
由于有opengrok 做了個tomcat的端口轉(zhuǎn)發(fā)
ProxyPass /source http://localhost:8081/source
ProxyPa***everse /source http://localhost:8081/source
重啟apache即可
客戶端配置source.list
sudo vim /etc/source.list
deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty?main?restricted deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-updates?main?restricted deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty?universe deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-updates?universe deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty?multiverse deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-updates?multiverse deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-backports?main?restricted?universe?multiverse deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-security?main?restricted deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-security?universe deb?[arch=amd64]?http://192.168.19.184/ubuntu/?trusty-security?multiversesudo apt-get update 即可
轉(zhuǎn)載于:https://blog.51cto.com/shippoo/1538583
總結(jié)
以上是生活随笔為你收集整理的apt-mirror建立本地ubuntu私有源的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unity3D热更新全书-脚本(二) 两
- 下一篇: 状态码常用对照表