第一步,安装所需的软件
apt install apt-mirror #将官方的软件源镜像包下载到本地
apt install apache2 #将软件源发布出去。
第二步,查看系统版本
不同的系统版本使用不同的apt仓库,根据自己的需要下载所需的仓库。
lsb_release -a #查看系统版本号
LSB Version: core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
第三步,根据需要修改配置文件。
以下注释内容是都是默认配置,如需自定义,取消注释即可。
############# config ubuntu14##################
# 所有下载数据的根目录是ubuntu14,默认即可
set base_path /var/data/ubuntu14/
# 镜像文件下载地址,默认即可。 ........ubuntu14/mirror。
# set mirror_path $base_path/mirror
# 临时索引下载文件目录,也就是存放软件仓库的dists目录下的文件(默认即可)........ubuntu14/skel
# set skel_path $base_path/skel
# 配置日志(默认即可) .........ubuntu14/var
# set var_path $base_path/var
# clean脚本位置 [不清楚作用]
# set cleanscript $var_path/clean.sh
# 架构配置,i386/amd64,默认的话会下载跟本机相同的架构的源.
# set defaultarch <running host architecture>
set defaulttarch amd64
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
# 下载线程数
set nthreads 20
set _tilde 0
#
############# end config ##############
#######################ubuntu官方源
#deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu xenial-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
####deb-src表示源码,一般不需要。
#deb-src http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu xenial-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
#clean http://archive.ubuntu.com/ubuntu
#####################更换为国内的 Aliyun,速度快
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
#其中的trusty表示的是不同的系统版本。
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
###(这里没有添加deb-src的源)
clean http://mirrors.aliyun.com/ubuntu
第四步,开始同步
apt-miiror #大概120g左右,根据网速,大概需要4个多小时。
#定时同步到本地。
第五步,
apache2默认网站目录是/var/www/html,所以做个软连接就可以直接访问。
ln -s /var/data/ubuntu18/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu
同步的镜像文件目录为 …/mirror/mirrors.aliyun.com/ubuntu/
第六步,客户端配置
修改/etc/apt/source.list文件,
#注释所有之前的,添加如下:
#将下面的ip和端口替换为自己apache服务器的。
deb [arch=amd64] http://192.168.10.20:80/ubuntu/ bionic main restricted universe multiverse
deb [arch=amd64] http://192.168.10.20:80/ubuntu/ bionic-security main restricted universe multiverse
deb [arch=amd64] http://192.168.10.20:80/ubuntu/ bionic-updates main restricted universe multiverse
deb [arch=amd64] http://192.168.10.20:80/ubuntu/ bionic-proposed main restricted universe multiverse
deb [arch=amd64] http://192.168.10.20:80/ubuntu/ bionic-backports main restricted universe multiverse
更新:
apt update
其他补充:
ubuntu LTS版本与代号的关系:
11.04: natty
11.10: oneiric
12.04: precise
12.10: quantal
13.04: raring
13.10: saucy
14.04: trusty
14.10: utopic
15.04: vivid
15.10: wily
16.04: xenial [y]
16.10: yakkety
18.04: bionic [y]
ubuntu18的配置文件:
# 所有下载数据的根目录是ubuntu18. ############ubuntu18.04配置文件
set base_path /var/data/ubuntu18/
set defaulttarch amd64
set nthreads 20
set _tilde 0
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
clean http://mirrors.aliyun.com/ubuntu
来源:CSDN
作者:未知的探索者
链接:https://blog.csdn.net/weixin_41272269/article/details/104730644