Proper Local Source Setup for apt Intranet under Ubuntu

Proper Local Source Setup for apt Intranet under ubuntu

Why is it built correctly because the construction process copies with the pit encountered on the web, and the amount is 100g at a time.What's more, the 16.04 system uses the 14.04 source, prompting apt-get install-f to execute. Never execute this command. I feel afraid to use this command in the future.Record it here

Reference to -> If your system is ubuntu14.04, copying is fine, but now Ubuntu 18.04, and you need to continue updating, here's how to build all versions of apt local sources.

Setup of APT local sources (for LAN apt-get sources or local sources)

This document describes building apt local sources using apt-mirror software

Requirements: Intranet development environments cannot access the external network for specific reasons, so they need an internal network source in the local environment to facilitate developers to download and install software
Recommendation: Avoid confusion by using a single disk to store source files or a separate directory

1. Install apt-mirror

apt-get install apt-mirror

2. Modify apt-mirror configuration file

Before modifying the configuration file, we first need to determine the version of our system, command: sudo lsb_release -a

$sudo lsb_release -a
    No LSB modules are available.
    Distributor ID:    Ubuntu
    Description:    Ubuntu 16.04 LTS
    Release:    16.04
    Codename:    xenial

Codename code means, 16.04 code xenial, so our next configuration file is related to xenial, of course 14.04 code is trusty, the same operation.
open Ali Yunyuan (You can also use other sources, the web address can own Baidu)
Enter the dists directory and find the question folder related to the system code in the directory. Generally, there are five folders. Copy the following rule text and replace the bold part with the corresponding five file directory names.Enter these five directories, which have four source-related directories (except by-hash). The directory names are compared with the italic sections below. Modify them if they are different.

deb http://mirrors.aliyun.com/ubu... xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubu... xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubu... xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubu... xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubu... xenial-backports main restricted universe multiverse

Then?

vim /etc/apt/mirror.list

Refer to the following configuration file:
Empty the original configuration file, modify the corresponding code part of the following configuration file, if you want to add more than one version of the source, you can add the corresponding rules below (that is, add the source address of the corresponding code)

############# config ##################
# The content of the following comments is the default configuration, if you need to customize, you can cancel the comment modification
set base_path /var/spool/apt-mirror
#
# Mirror file download address
# set mirror_path $base_path/mirror
# Temporary Index Download File Directory, which is the file in the dists directory where the software repository is stored (by default)
# set skel_path $base_path/skel
# Configuration log (default)
# set var_path $base_path/var
# clean script location
# set cleanscript $var_path/clean.sh
# Architecture Configuration, i386/amd64, downloads the source of the same architecture as the native machine by default
set defaultarch amd64
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
# Number of download threads
set nthreads 20
set _tilde 0
#
############# end config ##############
# Ali yun (no deb-src source added here)
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
 
clean http://mirrors.aliyun.com/ubuntu

3. Start synchronization

Execute apt-miiror

Then wait for a long time (this mirror is about 100G, depending on the network environment), the synchronized mirror file directory is / var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu/, of course, if you add another source, there is another directory with the name of the address in the / var/spool/apt-mirror/mirror directory.

Note: apt-mirror only needs to be re-run when apt-mirror is interrupted unexpectedly, apt-mirror supports breakpoint persistence; in addition, it needs to be deleted under the / var/spool/apt-mirror/var directory [sudo rm apt-mirror.lock] and restarted after it is closed unexpectedly.

4. Install apache2

apt-get install apache2

Since Apache2's default web file directory is located at / var/www/html, you can make a soft link (so that we can access it directly without having to import it directly)

ln -s /var/spool/apt-mirror/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu

Then you can access it at the following address

http://127.0.0.1/ubuntu   
#ip and port are native to your computer, where the port defaults to 80
 When testing, you may encounter a situation where you can't open it. Check if the iptables rules are restricted or selinux is a problem (I'm sure you already know that when you learn lanmp)

Client Configuration:

1. Edit/etc/apt/source.list, refer to the following (64-bit machine, ubuntu16.04 below), modify the corresponding code number, hardware architecture arch, add file

# Local Source      #ip and ports are native, with ports defaulting to 80
deb [arch=amd64] http://[host]:[port]/ubuntu/ xenial main restricted universe multiverse
deb [arch=amd64] http://[host]:[port]/ubuntu/ xenial-security main restricted universe multiverse
deb [arch=amd64] http://[host]:[port]/ubuntu/ xenial-updates main restricted universe multiverse  
deb [arch=amd64] http://[host]:[port]/ubuntu/ xenial-proposed main restricted universe multiverse
deb [arch=amd64] http://[host]:[port]/ubuntu/ xenial-backports main restricted universe multiverse

2. Update apt-get source

sudo apt-get update    #This step is important
sudo apt-get upgrade

Keywords: Linux Ubuntu sudo network vim

Added by Sware on Sun, 21 Jul 2019 19:21:03 +0300