版本16.04
1,更新本地源
apt-get update
apt-get upgrade
2,安裝apt-mirror
apt-get install apt-mirror
3,修改配置文件
root@VDIUBUNTU1604:~# cat /etc/apt/mirror.list
############# config ##################
# 以下注釋的內(nèi)容都是默認配置,如果需要自定義,取消注釋修改即可
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
# 下載線程數(shù)
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
4,同步到本地
apt-miiror
時間巨長,有117G
5,安裝Apache
apt-get install apache2
#創(chuàng)建索引
ln -s /var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu
6,訪問成功
http://ip:port/ubuntu

image.png
7,客戶端配置
root@VDIUBUNTU1604:~#vim /etc/apt/source.list
# Local Source #ip和port是自己本機的,其中端口默認為80
deb [arch=amd64] http://[ip]:[port]/ubuntu/ trusty main restricted universe multiverse
deb [arch=amd64] http://[ip]:[port]/ubuntu/ trusty-security main restricted universe multiverse
deb [arch=amd64] http://[ip]:[port]/ubuntu/ trusty-updates main restricted universe multiverse
deb [arch=amd64] http://[ip]:[port]/ubuntu/ trusty-proposed main restricted universe multiverse
deb [arch=amd64] http://[ip]:[port]/ubuntu/ trusty-backports main restricted universe multiverse
更新源
apt-get update
apt-get upgrade