Apt-Mirror: Build local Ubuntu private source

Source: Internet
Author: User

First, we need to install apt-Mirror.
$ Sudo apt-Get install apt-mirror

Suppose we put images and other files in the/service/Ubuntu Folder:

Please create the following folder in advance (mirror. List prompts you to create a folder in advance ):

/Service/Ubuntu
/Service/Ubuntu/Mirror
/Service/Ubuntu/skel
/Service/Ubuntu/var

Configure apt-Mirror:

$ Sudo VI/etc/APT/mirror. List
--------------------------------------------------------------
############# Config ##################
#
# Set base_path/var/spool/apt-mirror
#
# If you change the base path you must create the directories below with write privlages
#
# Set pai_path $ base_path/Mirror
# Set skel_path $ base_path/skel
# Set var_path $ base_path/var
# Set cleanscript $ var_path/clean. Sh
# Set defaultarch <running Host Architecture>

# Add or modify the following content:
Set base_path/service/Ubuntu

Set pai_path $ base_path/Mirror
Set skel_path $ base_path/skel
Set var_path $ base_path/var
Set cleanscript $ var_path/clean. Sh
Set nthreads 20
Set _ Tilde 0
#
############ End config ##############


# It is enough to synchronize common software.
Deb-i386 http://archive.Ubuntu.com/ubuntu hard main restricted universe multiverse
Deb-i386 http://archive.ubuntu.com/ubuntu hard-Updates main restricted universe multiverse
Deb-i386 http://archive.ubuntu.com/ubuntu hard-backports main restricted universe multiverse
Deb-i386 http://archive.ubuntu.com/ubuntu hard-security main restricted universe multiverse
Deb-i386 http://archive.ubuntu.com/ubuntu hard-proposed main restricted universe multiverse

# When some software packages are upgraded on the server or are no longer needed on the server, we use apt-mirror to synchronize with the server, A clean is generated under $ var_path. sh script to list legacy and useless software packages that are left locally. You can manually run this script to delete software packages that are left locally and do not need to be used.
Clean http://archive.ubuntu.com/ubuntu

-----------------------------------------------------------------------------

If you use a package in an amd64-bit architecture, you can add a deb-amd64 tag
If the format of Deb HTTP... is used directly without adding anything, only the software packages in the architecture used by the current system are synchronized in the same step. For example, in a 64-bit system, debhttp directly synchronizes only 64-bit software packages. If you are still in trouble, just change the set defaultarch <running hostarchitecture> parameter, for example, set defaultarch i386, so that you can use debhttp ..... in this format, only the i386 software package is synchronized in the same step.

If you still want the source code, you can add the source code to the mirror. List for synchronization, such as adding the Deb-Src mark. You can append the corresponding tag for other things.


After configuration, We can synchronize with the specified image.
$ Sudo apt-mirror

If this is the first synchronization, it may take several days for the official image to complete synchronization. If it is synchronized with the domestic source, only common software will be synchronized, with an average speed of 1 Mbps (byte) it takes about 5-8 hours to synchronize 30 GB of data.

After synchronization, we can use clean. Sh to clear useless software packages (this document uses set base_path/Server/Ubuntu as an example ):
$ Sudo sh/service/Ubuntu/var/clean. Sh

After the update, you can use Apache to publish the source image.



In the preceding excerpt, 64-bit source synchronization for 68 Gb is mirrors.163.com.


Configure apache2 below

Go to httpd. conf to modify
# <Directory/>
# AllowOverride none
# Require all denied
# </Directory>

Change
<Directory/>
Options followsymlinks
AllowOverride none
Order deny, allow
Allow from all
</Directory>

Add a virtual directory to the <ifmodule alias_module> node.
<Ifmodule alias_module>
Alias/Ubuntu/workspace/Ubuntu/mirror/mirrors.163.com/ubuntu
</Ifmodule>
Add virtual directory permissions
<Directory "/workspace/Ubuntu/mirror/mirrors.163.com/ubuntu">
Options indexes followsymlinks
AllowOverride none
Require all granted
</Directory>

Because opengrok implements Tomcat port forwarding
Proxypass/source http: // localhost: 8081/source
Proxypassreverse/source http: // localhost: 8081/source


Restart Apache.


Configure source. List on the client


Sudo Vim/etc/source. List

deb [arch=amd64] http://192.168.19.184/ubuntu/ trusty main restricteddeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-updates main restricteddeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty universedeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-updates universedeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty multiversedeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-updates multiversedeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-backports main restricted universe multiversedeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-security main restricteddeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-security universedeb [arch=amd64] http://192.168.19.184/ubuntu/ trusty-security multiverse

Sudo apt-Get update


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.