Use APT-mirror to configure the Ubuntu local software repository in four steps
Today, we will show you how to configure the local software repository directly through the official Ubuntu software repository on your Ubuntu PC or Ubuntu server. Creating a local software repository on your computer has many benefits. If you have many computers that require software installation, security upgrades, and repair patches, configuring a local software repository is an efficient way to do this. All software packages to be installed can be downloaded from your local server through a fast LAN connection, which can save your network bandwidth and reduce the annual cost of Internet access...
You can use multiple tools to configure a local Ubuntu software repository on your local PC or server, but in this tutorial we will introduce you to APT-Mirror. Here, we will mirror the default image package to our local server or PC, and in your local or external hard disk, we need at least 120 GB or more available space. We can configure an HTTP or FTP server to share the software repository with the local system client.
We need to install the Apache network server and APT-Mirror to start our work. The steps for configuring a working local software repository are as follows:
1. Install the required software package
We need to get all the software packages from the public software package warehouse of Ubuntu, and then save them in our local Ubuntu server hard disk.
First, install a Web server to host our local software repository. Here we will install the Apache Web server, but you can install any of your favorite Web servers. For http, Web servers are required. If you need to configure the ftp protocol and rsync protocol, you can also separately install the FTP server, such as proftpd, vsftpd, and Rsync.
- $ Sudo apt-get install apache2
Then we need to install apt-mirror:
- $ Sudo apt-get install apt-mirror
Note: As I mentioned earlier, we need at least 120 GB of available space for all software packages to be mirrored or downloaded.
2. Configure APT-Mirror
Now, create a directory on your hard disk to save all the software packages. For example, if we create a directory named/linoxide, we will save all the software packages in this directory:
- $ Sudo mkdir/linoxide
Now open the file/etc/apt/mirror. list:
- $ Sudo nano/etc/apt/mirror. list
Copy the following command line configuration to the mirror. list file and modify it as needed:
- ############# Config ##################
- #
- Set base_path/linoxide
- #
- # 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>
- # Set postmir_script $ var_path/postmirror. sh
- # Set run_postmirror 0
- Set nthreads 20
- Set _ tilde 0
- #
- ############ End config ##############
-
- Deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
- Deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
- Deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
- # Deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
- # Deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
-
- The deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
- Deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
- Deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
- # Deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
- # Deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
-
- Clean http://archive.ubuntu.com/ubuntu
Note: You can change the official website of the backup storage Server to the address of the Server closest to you. You can find these Server addresses by visiting the Ubuntu Mirror Server. If you do not care too much about the image completion time, you can follow the default official image server website.
Here, we will mirror the latest and largest Ubuntu LTS release version --- Ubuntu 14.04 LTS (Trusty Tahr) --- package repository, so the version number in the above configuration is trusty. If we need to image Saucy or other Ubuntu Release versions, please change the above trusy to the corresponding code.
Now, we must run apt-mirror to download or mirror all the software packages in the official repository.
- Sudo apt-mirror
The time it takes to download all the software packages from the Ubuntu server depends on the network connection speed and performance between you and the backup storage. Here I interrupted the download because I have downloaded it...
3. Configure the network server
To allow other computers to access this software repository, you need a Web server. You can also do this through ftp, but I chose to use a Web server because I mentioned using a Web server in step 1 above. Therefore, we need to configure the Apache server:
We will create a symbolic link to the Apache managed directory ---/var/www/ubuntu --- for our local software repository directory.
- $ Sudo ln-s/linoxide/var/www/ubuntu
- $ Sudo service apache2 start
The above command will allow us to browse our image software Repository from the local host (localhost) --- http: // 127.0.0.1 (by default.
4. Configure the client
Finally, we need to add software sources to other computers so that they can obtain software packages or software repositories from our computers. To achieve this goal, we need to edit the/etc/apt/sources. list file and add the following command:
- $ Sudo nano/etc/apt/sources. list
Add the following line to/etc/apt/sources. list and save it.
- Deb http: // 192.168.0.100/ubuntu/trusty main restricted universe
Note: 192.168.0.100 is the IP address of the LAN on our server computer. You need to replace it with the IP address of the LAN on your server computer.
- $ Sudo apt-get update
Finally, we completed the task. Now, you can use the sudo apt-get install packagename command to install the required software package from your local Ubuntu software repository, which will be high-speed and consume a small amount of bandwidth.