How to create an Ubuntu 20.04 repository server?

Windows Articles

How to create backups in Windows 10 with FileFort Backup

There is no doubt that the computer is an essential element in our lives. Indeed, its uses go beyond work or study....

Trisquel 9.0 available

Trisquel is a GNU/Linux distribution endorsed and supported by the Free Software Foundation. This means that in addition to incorporating the Linux...

How to install PandoraFMS on CentOS 8?

Worldwide many IT infrastructures are running Linux on one of their servers. This opens the door to an endless number of different...

How to force close a program using PowerShell

Hi! We have mentioned in the past that Windows allows you to open multiple programs at once. In fact, that is one...

How to install the Owncloud desktop client Ubuntu 20.04?

In this post, You will learn how to install the Owncloud desktop client on Ubuntu 20.04. Many users and...
angeloma
angeloma
Senior Writer and partner

Many organizations use Linux for all their computers or at least for the servers. It is also a common practice to create an Ubuntu 20.04 repository server to make all packages available from the local network. This also increases security because it allows you to manage the source of the packages. In this post, you will learn how to do it step by step and in a very easy way.

Creating an Ubuntu 20.04 repository server

Some considerations

The process is quite simple but it requires a very good internet connection and above all a lot of space on the hard disk.

Remember that during the process all the packages will be cloned, so we would be talking about at least 1 Tb of space for a particular version of Ubuntu.

So, if you can do so I think you will have no problem completing the tutorial.

Install and configure Apache webserver

In order to make our repository accessible from the internet or the internal network using the web browser, like any other online repository, it is necessary to have a web server.

So, install the Apache webserver:

sudo apt install apache2
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-5.4.0-26 linux-headers-5.4.0-26-generic linux-image-5.4.0-26-generic linux-modules-5.4.0-26-generic linux-modules-extra-5.4.0-26-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 ssl-cert
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 1865 kB of archives.

It then creates a folder dedicated to packages within Apache DocumentRoot. Then make Apache the owner of the

sudo mkdir -p /var/www/html/packages
sudo chown www-data:www-data /var/www/html/packages

By recommendation, the folder where Apache DocumentRoot is located should be in a logical volume partition so that it can be increased in size without affecting the system.

Creating an Ubuntu 20.04 repository server

The tool that allows us to do all this magic is apt-mirror. Basically what it does is a clone of all the packages of the Ubuntu repositories on our computer.

One aspect that makes this tool very reliable is that we can specify which repositories we want to take for the copy.

So, to install it, just run the following command:

sudo apt install apt-mirror
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-5.4.0-26 linux-headers-5.4.0-26-generic linux-image-5.4.0-26-generic linux-modules-5.4.0-26-generic linux-modules-extra-5.4.0-26-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
apt-mirror
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.3 kB of archives.

It then updates the entire APT cache to ensure that all information is up to date.

sudo apt update
1.- Install Apt-mirror
1.- Install Apt-mirror

Now we have to configure which repositories we will use to create the repository.

All these settings can be defined in the file /etc/apt/mirror.list but before modifying it, create a backup of it.

sudo cp /etc/apt/mirror.list /etc/apt/mirror.list.bak

Then you can modify it with the text editor of your choice:

sudo nano /etc/apt/mirror.list
2.- Preparing the system for starting the process
2.- Preparing the system for starting the process

And leave it as shown in the image. You can also configure as many repositories as you want. And you may have to modify the Ubuntu release because in my case it was configured for artful.

Selecting the source file repositories will considerably increase the size of the download. So, it’s a good idea to think about it first.

In this file, you have to make sure to change the value of set base_path by the path where we set the repository. In my case /var/www/html/packages/

Save the changes and close the editor.

It’s time to create an Ubuntu 20.04 repository server and for that, you only have to execute the command apt-mirror

sudo apt-mirror
3.- Creating an Ubuntu 20.04 repository server
3.- Creating an Ubuntu 20.04 repository server

Keep in mind that the process is extremely long and this will vary greatly depending on the Internet connection you have.

Once the process is finished, the server will be configured and ready to be used.

If you open your web browser and go to the address http://192.168.1.43/packages/ you will see the repository working. Of course, remember that you have to have port 80 available in the firewall and if the computer has a domain name you can also access it that way.

4.- Local repository working
4.- Local repository working

Configuring Linux clients to use the newly created repository

Now all you have to do is to modify the file /etc/apt/source.list in all Linux clients and remove all references to the repositories and add your own.

sudo nano /etc/apt/source.list

And comment on all the repositories and start adding your own. For example:

deb http://192.168.1.200/packages/mirror/archive.ubuntu.com/ focal main restricted universe multiverse

And so on with every repository.

Save your changes, close the editor and you’re done. Just refresh the APT cache and that is it.

sudo apt update

Conclusion

Creating an Ubuntu repository server is an increasingly common solution among companies that use Ubuntu because it ensures that the packages they install are not compromised or to save bandwidth.

So, share this post and join our Telegram Channel and give us a like on Facebook.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to create backups in Windows 10 with FileFort Backup

There is no doubt that the computer is an essential element in our lives. Indeed, its uses go beyond work or study....

Trisquel 9.0 available

Trisquel is a GNU/Linux distribution endorsed and supported by the Free Software Foundation. This means that in addition to incorporating the Linux...

How to install PandoraFMS on CentOS 8?

Worldwide many IT infrastructures are running Linux on one of their servers. This opens the door to an endless number of different...

How to force close a program using PowerShell

Hi! We have mentioned in the past that Windows allows you to open multiple programs at once. In fact, that is one...

How to install the Owncloud desktop client Ubuntu 20.04?

In this post, You will learn how to install the Owncloud desktop client on Ubuntu 20.04. Many users and...
x