There are multiple reasons to have a local repository. The main reason would be to capture large updates downstream and re-distribute them via a local repository to save on Internet usage. Other reasons someone might want to do this would be to more easily distribute software that isn’t found on the default Ubuntu servers. So, how do you get it installed? Let’s find out!

Installing Apache

For the local repository to work, an Apache server will need to be set up on the host system. Open up a terminal and enter the following command:

This will set up a website on Ubuntu and the folder structure that it needs to function. It can be tested out in any web browser by going to “http://localhost” or the LAN IP address of the machine using it (http://192.168.1.XX). The Apache server folder structure lies entirely in “/var/www/.” The default website page that the server sets up is in “/var/www/html/” and is labeled as “index.” Setting up a local repository has little use for this default Apache page. However, it may be a good idea to make a start page to advertise ways LAN users can connect to the local repository.

Configuring Directories

The local Ubuntu package repository will not work without the correct folder structure. The Debian package repository directory structure is necessary here. In a terminal, do the following:

Now that the user has root permission, start off by entering the correct directory with the cd command. The first part of the package repository structure is the “deb” folder. Create it with the mkdir command.

Creating the APT catalog

The folders are set up. Now it is time to configure the catalog for APT to use. First, place any and all .Deb package files you’d like to keep in either the “/var/www/debs/amd64” folder or the “/var/debs/i386” folder (for 32 bit packages). or for 32bit

Setting up clients

With everything set up, the APT repository is no different than any other repository that a user would find online. This makes it very simple and easy to add to Ubuntu. Inside the sources file, add your LAN APT repository using your APT servers LAN IP address. This is found with ip addr show in the terminal. Look for “inet 192.168..” under the network adapter on the system communicating with the Internet. Alternatively, log into your router and find the IP address it has given the machine hosting the APT repo server. Note: to make things easier on laptops, consider port forwarding the IP address of the APT repo host machine outside of LAN to the Internet on port 80 and using that in place of a local IP address like the tutorial says. This will ensure that updates will not break when a computer leaves the LAN for a brief time.

With the internal IP address known, enter the following in the terminal: This will allow the user to edit the list of servers that Ubuntu pings for updates. Add the repository to the list and save it. or for 32bit Press “Ctrl + o” to save the changes once done. Finally, update Ubuntu by doing sudo apt-update. Note: replace X with whatever internal IP address your router has given out. Alternatively, change 192.168.1.X with the external IP address so that your APT server is ping-able when not at home.

Conclusion

Now that everything is set up, any user with the repository in the “sources.list” file will be able to easily get packages from the local APT cache as if they were regular updates. No other special configurations required, and bandwidth savings can begin. This method is the superior way to go as it makes it possible to host packages locally for bandwidth sake.The other positive is that there is very little configuration to do, and end-users will not know any better. Would you host your own APT cache server on Ubuntu to save bandwidth? Tell us below!