ubuntu搭建apt內網本地源


ubuntu搭建apt內網本地源

1.安裝apt-mirror

$ sudo apt-get install apt-mirror

2.修改apt-mirror配置文件

2.1確定系統版本

在修改配置文件之前,首先要確定服務器系統的版本(在內網中不能聯網的那台機器),命令:

$ sudo lsb_release -a		#方法1
-->

No LSB modules are available.
 Distributor ID: Ubuntu
 Description: Ubuntu 18.04.4 LTS
 Release: 18.04
 Codename: bionic		#Codename表示代號
 # 14.04代號trusty,16.04代號xenial,18.04代號bionic
 
 
 $ uname -a		#方法2
-->

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		#方法3
-->

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

2.2修改軟件源配置

修改可聯網機器的軟件源文件,使軟件源版本與內網不能聯網機器的版本對應

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

更改配置文件:

$ sudo 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、同步軟件源

$ sudo apt-miiror			#執行此命令,將會下載軟件源內所有的文件。

會出現類似倒計時一樣 20 19 18
下載大約135G左右,所以下載目錄空間要夠。

4、安裝web服務

$ sudo apt-get install apache2		#安裝apache2服務

Apache2的默認網頁文件目錄位於/var/www/html,可以做個軟鏈接

$ ln -s /home/test/ubuntu/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu

通過瀏覽器訪問:http://192.168.20.6

ip是上述配置web服務,作為更新源的機器。 port:端口默認80

5.內網機器配置

編輯/etc/apt/source.list,參考以下內容(以下是64位機,ubuntu18.04),修改相應的代號,硬件架構arch,加入文件

# Local Source     
deb [arch=amd64] http://192.168.20.6/ubuntu/ bionic main restricted universe multiverse
deb [arch=amd64] http://192.168.20.6/ubuntu/ bionic-security main restricted universe multiverse
deb [arch=amd64] http://192.168.20.6ubuntu/ bionic-updates main restricted universe multiverse  
deb [arch=amd64] http://192.168.20.6/ubuntu/ bionic-proposed main restricted universe multiverse
deb [arch=amd64] http://192.168.20.6/ubuntu/ bionic-backports main restricted universe multiverse

更新apt-get源

sudo apt-get update
sudo apt-get upgrade


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM