ubuntu下的apt内网本地源 搭建


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地址访问

http://192.168.64.156(端口默认80,可以不加)
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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM