Using ‘on demand’ yum Repositories

When you run an install or update command using yum, it checks the list of repositories (repos) in /etc/yum.repos.d/ and tries to install/update a package using the details in the config files found there. However, in some cases it’s not necessary or desirable to leave a particular repo enabled all the time.

For example, if you installed PHP from a non-standard repo (let’s call it ‘example’), but don’t want to use it for any other packages, you would edit the relevant config file:

vim /etc/yum.repos.d/example.repo

- and disable it as a ‘default’ option by setting the enabled directive in the config file to 0, e.g.

enabled=0

To flush the yum cache you would then run:

yum clean all

Once done, any further yum commands that don’t specifically call the repo would ignore this repo and just install packages from the remaining actives repos. The repo becomes a sort of ‘on demand’ service.

To force the use of a disabled repo, you need to use the enablerepo switch when running yum. So, if we want to use example.repo to install php-devel package, we would run the following command:

yum –enablerepo=example install php-devel

This will then use the repo details stored in example.repo, ignoring the enabled=0 directive, to install the package.

Note: The repo config files are usually appended with the .repo extension. The name of the repo is listed in the header of the config file between square brackets, e.g. [example]

This entry was posted in Managed Hosting. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>