Adding repositories to a Linux server

Posted:  May 14th, 2016

 

KEKhost/KEKhosting offers servers with three different distributions of Linux: CentOS, Debian and Ubuntu. Each of these distributions offer standard repositories for software packages, from which applications can be easily installed.

 

These standard repositories contain a wide variety of software packages, but as these packages are curated by the distributions, they are chosen for stability and licensing. It can happen that a necessary software package is not available in the standard repositories. In these cases, extra repositories can be added to your server, thus allowing different or newer software to be installed.

 

CentOS

 

There are many different repositories in CentOS, only some of which are enabled by default. The core enabled repositories are [base], [updates], [addons], and [extras]. The other repositories are not enabled, as they could replace your core packages.

 

To add a repository to your CentOS server, simply move the .repo file to the repository directory:

 

    /etc/yum.repos.d/

 

.repo files are available from the websites of the repositories. You must be logged in as root to move the .repo files.

 

Ubuntu

 

There are four main repositories in Ubuntu: Main, Restricted, Universe, and Multiverse.

 

Main is the default basic repository of officially supported software, as curated by Canonical.

 

Restricted is a repository containing supported software which is not open source, such as MP3 or Flash.

 

Universe is maintained by the greater Ubuntu community of users and developers. These are not officially supported, but tend to be the newer releases.

 

Multiverse contains software which is restricted in some way, either by licensing terms or by legal jurisdiction. To ensure that your usage is allowed, verify against your local laws and regulations. Please note that Multiverse packages may not receive security updates in a timely fashion.

 

KEKhost/KEKhosting strongly recommends using the default Main repository. Any installation of non-supported software is strictly at the customer's own risk.

 

If you still wish to add further repositories, follow these steps:

 

Start by logging into your server as root.

 

Open the following file in your chosen editor. In this example, we use nano:

 

    nano /etc/apt/sources.list

 

This file contains the list of repositories used by your server.

 

Simply add the repository names that you wish to use. For example, if you were adding the 'universe' repository for Ubuntu 12.04 LTS ('quetzal'), you would add these lines to sources.list:

 

deb http://us.archive.ubuntu.com/ubuntu/ quetzal universe

deb-src http://us.archive.ubuntu.com/ubuntu/ quetzal universe

deb http://us.archive.ubuntu.com/ubuntu/ quetzal universe

deb-src http://us.archive.ubuntu.com/ubuntu/ quetzal universe

 

For other versions of Ubuntu, simply replace 'quetzal' with the correct version name, i.e. lucid, hardy, etc., and for different repositories, simply replace 'universe'. You can also add multiple new repositories by adding the same lines again after replacing the appropriate names.

 

Once you are done editing the file, save and quit. Then update your repositories by running this command:

 

    apt-get update

 

After your server has finished updating package lists, you will be able to install new packages using the APT command.

 

Debian

 

As Debian and Ubuntu are built using the same framework, you can add repositories in the same way as in Ubuntu. That said, however, the main repositories in Debian are named differently from Ubuntu.

 

We strongly recommend using the default repositories.

 

Other than Main, which is Debian's default repository, there is also Contrib and Non-Free, which are restricted by laws or license restrictions. Please verify your local legislation to ensure that your usage is allowed.

 

In this example, you would add these lines to your Debian server's /etc/apt/sources.list file:

 

    deb http://http.us.debian.org/debian/ squeeze main contrib non-free

    deb-src http://http.us.debian.org/debian/ squeeze main contrib non-free

 

Here, the Contrib and Non-Free repositories have been enabled for Debian 6, also known as "Squeeze". If you are running a different version of Debian, simply change 'squeeze' for the appropriate version name.

 

For further information about Debian's packaging system, please consult the official documentation, available at the following link:

 

http://www.debian.org/distrib/packages

 

 

As with Ubuntu, once you are done editing the file, save and quit. Then update your repositories by running this command:

 

    apt-get update

 

After your server has finished updating package lists, you will be able to install new packages using the APT command.