版本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 ##################
# 以下注释的内容都是默认配置,如果需要自定义,取消注释修改即可
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
4,同步到本地
apt-miiror
时间巨长,有117G
5,安装Apache
apt-get install apache2
#创建索引
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
网友评论