ubuntu查看版本號命令:
sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
uname -a
Linux 123 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
cat /proc/version
Linux version 5.3.0-42-generic (buildd@lcy01-amd64-019) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020
1、安裝apt-mirror
apt-get install apt-mirror
2、修改apt-mirror配置文件
在修改配置文件之前,我們首先要確定自己系統的版本,命令:sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Codename代號的意思,
6.04代號xenial
14.04代號trusty
18.04代號bionic
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
更改配置文件
vim /etc/apt/mirror.list
配置文件:
# 以下注釋的內容都是默認配置,如果需要自定義,取消注釋修改即可 set base_path /home/test/ubuntu ----下載路徑
# # 鏡像文件下載地址 # 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 ############## 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
3、開始同步
執行 apt-miiror
會出現類似倒計時一樣 20 19 18
下載大約135G左右,所以下載目錄空間要夠。
4、安裝apache2
apt-get install apache2
Apache2的默認網頁文件目錄位於/var/www/html,可以做個軟鏈接
ln -s
/home/test/ubuntu
/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu
通過ip地址訪問
ip是配置apache2的電腦 port:端口默認80
客戶端配置:
1、編輯/etc/apt/source.list,參考以下內容(以下是64位機,ubuntu18.04),修改相應的代號,硬件架構arch,加入文件
# Local Source deb [arch=amd64] http://192.168.64.156/ubuntu/ xenial main restricted universe multiverse deb [arch=amd64] http://192.168.64.156/ubuntu/ xenial-security main restricted universe multiverse deb [arch=amd64] http://192.168.64.156/ubuntu/ xenial-updates main restricted universe multiverse deb [arch=amd64] http://192.168.64.156/ubuntu/ xenial-proposed main restricted universe multiverse deb [arch=amd64] http://192.168.64.156/ubuntu/ xenial-backports main restricted universe multiverse
2、更新apt-get源
sudo apt-get update sudo apt-get upgrade
參考文章: https://www.jianshu.com/p/3e3f34f0ac03