ubuntu下的apt-get內網本地源的搭建


APT本地源的搭建(可用於局域網apt-get源搭建或者本地源)
本文檔介紹使用apt-mirror軟件搭建apt本地源
需求:內網開發環境由於其特定原因不能上外網,所以需要本地環境下的內網源來方便開發人員下載安裝軟件
建議:單獨使用一塊磁盤來存放源文件或者單獨一個目錄下,避免混淆
思路:這里通過使用一個內網下的httpd服務來實現倉庫功能,客戶端直接進行配置連接到服務端即可
服務端配置如下:
1、安裝apt-mirror
apt-get install apt-mirror

 2、修改apt-mirror配置文件

vim /etc/apt/mirror.list

 

參考以下配置文件: 清空原有的配置文件,直接使用以下配置文件即可 
############# config ################## # 以下注釋的內容都是默認配置,如果需要自定義,取消注釋修改即可 set base_path
/var/spool/apt-mirror # # 鏡像文件下載地址 # set mirror_path $base_path/mirror # 臨時索引下載文件目錄,也就是存放軟件倉庫的dists目錄下的文件(默認即可) # set skel_path $base_path/skel # 配置日志(默認即可) # set var_path $base_path/var # clean腳本位置 # set cleanscript $var_path/clean.sh # 架構配置,i386/amd64,默認的話會下載跟本機相同的架構的源 set defaultarch amd64 # set postmirror_script $var_path/postmirror.sh # set run_postmirror 0 # 下載線程數 set nthreads 20 set _tilde 0 # ############# end config ############## # Ali yun(這里沒有添加deb-src的源) deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse clean http://mirrors.aliyun.com/ubuntu

 3、開始同步

執行 apt-miiror

 然后等待很長時間(該鏡像差不多100G左右,具體時間看網絡環境),同步的鏡像文件目錄為/var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu/,當然如果增加了其他的源,在/var/spool/apt-mirror/mirror目錄下還有其他的地址為名的目錄。

  4、安裝apache2  
apt-get install apache2

 由於Apache2的默認網頁文件目錄位於/var/www/html,因此,可以做個軟鏈接(這樣我們就可以直接訪問了,無需將其直接導入該目錄) 

ln -s /var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu

 

  然后就可以通過如下地址訪問了
http://[host]:[port]/ubuntu   #ip和port是自己本機的,其中端口默認為80
在測試時可能遇到打不開的情況,查看下iptables規則是否限制或者selinux的問題(這點相信大家在學習lanmp的時候都已經了解過了)

 

客戶端配置:
1、編輯/etc/apt/source.list,加入以下內容
# Local Source      #ip和port是自己本機的,其中端口默認為80
deb [arch=amd64] http://[host]:[port]/ubuntu/ trusty main restricted universe multiverse
deb [arch=amd64] http://[host]:[port]/ubuntu/ trusty-security main restricted universe multiverse
deb [arch=amd64] http://[host]:[port]/ubuntu/ trusty-updates main restricted universe multiverse  
deb [arch=amd64] http://[host]:[port]/ubuntu/ trusty-proposed main restricted universe multiverse
deb [arch=amd64] http://[host]:[port]/ubuntu/ trusty-backports main restricted universe multiverse
2、更新apt-get源
apt-update    #這步很重要

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM