Home / Install yum with rpm on CentOS

Install yum with rpm on CentOS

I set up a VPS (Virtual Private Server) with Net24 today with CentOS 5.0 i386 as the virtual server operating system. After logging in as root I discovered the operating system install was pretty minimal and didn’t include yum for package management, so I had to manually install yum with rpm.

I found a page about how to install yum with OpenVZ, and although Net24 use Virtuozzo and not OpenVZ, the instructions were what I needed to be able to install yum on CentOS 4 and CentOS 5 using RPM.

I used the list of files to create a single command as shown below:

for file in
    gmp-4.1.4-10.el5.i386.rpm
    readline-5.1-1.1.i386.rpm
    python-2.4.3-19.el5.i386.rpm
    libxml2-2.6.26-2.1.2.i386.rpm
    libxml2-python-2.6.26-2.1.2.i386.rpm
    expat-1.95.8-8.2.1.i386.rpm
    python-elementtree-1.2.6-5.i386.rpm
    sqlite-3.3.6-2.i386.rpm
    python-sqlite-1.1.7-1.2.1.i386.rpm
    elfutils-0.125-3.el5.i386.rpm
    rpm-python-4.4.2-37.el5.i386.rpm
    m2crypto-0.16-6.el5.1.i386.rpm
    python-urlgrabber-3.1.0-2.noarch.rpm
    yum-3.0.5-1.el5.centos.2.noarch.rpm
  do rpm -Uvh http://mirror.centos.org/centos-5/5.0/os/i386/CentOS/$file;
done

The nice thing about doing it this way is that if you decided to use a local/faster mirror you only need to change the base site in one place (ie changing http://mirror.centos.org/centos-5/ in the above to your mirror’s location of the CentOS files).

After installing yum you then need to run:

yum -y update

This will update the yum database and produce output along these lines:

Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
base                      100% |=========================| 1.1 kB    00:00
updates                   100% |=========================|  951 B    00:00
addons                    100% |=========================|  951 B    00:00
extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 798 kB    00:06
base      : ################################################## 2334/2334
Added 2334 new packages, deleted 0 old in 9.51 seconds
primary.xml.gz            100% |=========================| 323 kB    00:00
updates   : ################################################## 731/731
Added 731 new packages, deleted 0 old in 4.01 seconds
primary.xml.gz            100% |=========================|  157 B    00:00
Added 0 new packages, deleted 0 old in 0.00 seconds
primary.xml.gz            100% |=========================|  66 kB    00:00
extras    : ################################################## 251/251
Added 251 new packages, deleted 0 old in 0.89 seconds
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for kernel-headers to pack into transaction set.
kernel-headers-2.6.18-8.1 100% |=========================| 122 kB    00:00
---> Package kernel-headers.i386 0:2.6.18-8.1.14.el5 set to be updated
---> Downloading header for tzdata to pack into transaction set.
tzdata-2007h-1.el5.noarch 100% |=========================| 183 kB    00:00
---> Package tzdata.noarch 0:2007h-1.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Updating:
 kernel-headers          i386       2.6.18-8.1.14.el5  updates           728 k
 tzdata                  noarch     2007h-1.el5      updates           746 k

Transaction Summary
=============================================================================
Install      0 Package(s)
Update       2 Package(s)
Remove       0 Package(s)

Total download size: 1.4 M
Downloading Packages:
(1/2): kernel-headers-2.6 100% |=========================| 728 kB    00:01
(2/2): tzdata-2007h-1.el5 100% |=========================| 746 kB    00:02
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key)