Get yum to install a specific package version

  • by Tim White
  • posted 2010.07.29
  • 6 Comments
  • 8892 views
yum fun

yum fun

Every once in a while you may need to install a specific version of a package on your system. If you're using the yum package manager, it isn't blatantly obvious how to do this, even after pouring over the man pages.

So let's do this thing.

First, if you've already installed a newer version of the package, you'll have to downgrade it. In that case, make sure you've got yum's downgrade plugin installed:

# yum install yum-allowdowngrade

Second, do you know exactly which package version you want to install? If not, list the all available versions using the --showduplicates flag. This example looks for available versions of the GD extension for PHP.

# yum --showduplicates list php-gd

Available Packages
php-gd.i386                    5.2.3-3.el5s2                        testing
php-gd.i386                    5.2.6-2.el5s2                        testing
php-gd.i386                    5.2.9-2.el5.centos                   testing
php-gd.i386                    5.2.10-1.el5.centos                  testing

Yum uses the RPM package manager, and it's package names are based on the RPM package label format. In the above example, the first column displays the package name and architecture in the format NAME.ARCHITECTURE. The middle column displays the version and release info in the format VERSION-RELEASE. Don't ask me why yum rearranges the RPM package label format.

Anyways, if you're downgrading, remove the previous package:

# yum remove php-gd

Now that you know which version to install, it's a matter of specifying the package name with the version. Use the format NAME-VERSION.

# yum install php-gd-5.2.6

Or if you want to get even more specific, use NAME-VERSION-RELEASE (which might be easier to copy/paste since VERSION-RELEASE is the second column).

# yum install php-gd-5.2.6-2.el5s2

If you're downgrading, you may need to throw in the --allow-downgrade flag.

# yum --allow-downgrade install php-gd-5.2.6

And you should be good to go. If you want to lock the version you installed to prevent any future updates, install the versionlock plugin.

# yum install yum-versionlock

Then lock it.

# yum versionlock php-gd

Comments

  1. James
    2011.07.03

    Thanks! Helped me out a bunch.

  2. [...] [...]

  3. [...] to a link to someone else’s site.. in the interest of brevity, I’m doing just that. http://www.zulius.com/how-to/yum-install-specific-package-version/ Like this:LikeBe the first to like this [...]

  4. joe
    2011.12.06

    dosen't work on centos6

  5. Jack
    2012.01.25

    Hi,

    I type yum install yum-allowdowngrade

    but yum say no package for yum-allowdowngrade.

    OS is centos-64bit - centos 6.2. Do i need to point yum to a repository.

    Any help is greatly appreciated

    jack

  6. 2012.01.25

    jack, you need to read the instructions more carefully, you aren't supposed to type "yum install yum-allowdowngrade"

Leave a Comment