apt-get install apt-mirror
二、修改apt-mirror配置文件html
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
三、開始同步linux
執行 apt-miiror
而後等待很長時間(該鏡像差很少100G左右,具體時間看網絡環境),同步的鏡像文件目錄爲/var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu/,固然若是增長了其餘的源,在/var/spool/apt-mirror/mirror目錄下還有其餘的地址爲名的目錄。shell
注意:當apt-mirror 被意外中斷時,只須要從新運行便可,apt-mirror支持斷點續存;另外,意外關閉,須要在/var/spool/apt-mirror/var目錄下面刪除 apt-mirror.lock文件【 sudo rm apt-mirror.lock 】,以後執行apt-mirror從新啓動數據庫
apt-get install apache2
因爲Apache2的默認網頁文件目錄位於/var/www/html,所以,能夠作個軟連接(這樣咱們就能夠直接訪問了,無需將其直接導入該目錄) apache
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的時候都已經瞭解過了)
# 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
apt-update #這步很重要