Get yum to install a specific package version

yum package manager

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


  1. James

    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. Like this:LikeBe the first to like this [...]

  4. joe

    dosen't work on centos6

  5. Jack


    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


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

  7. Yuriy

    Jack, I have same issue.

    # yum install yum-allowdowngrade
    Loaded plugins: fastestmirror, security
    Loading mirror speeds from cached hostfile
    * base:
    * epel:
    * extras:
    * ius:
    * rpmforge:
    * updates:
    Setting up Install Process
    No package yum-allowdowngrade available.
    Error: Nothing to do

  8. Good ! This is Just I want

    Thanks very much !

  9. Amr Farid

    Jack, You don't have to install yum-allowpdowngrade , you can use
    yum --showduplicates list directly

  10. yum install yum-versionlock
    Might wanna look at this tool, seems to do the same, no idea of use yet. but its the one I found.

  11. Jasper

    I know now xD. can't edit my comment but hereby:

    yum install yum-versionlock
    yum --allow-downgrade install bind-libs-9.8.2-0.17.rc1.el6_4.5.x86_64
    yum versionlock bind-libs

  12. […] Get yum to install a specific package version […]

  13. Very Good Tutorials , I was looking for old cpanel to test an old php script . just happy to install old version . anyways there lots of missing information but its gives me to correct one for setting php 5.2 in my 32bit Centos 6 KVM VPS.

  14. very helpful and techful topic..

Leave a Comment