yum fails on my VPS / the RPM database on my VPS is corrupt

Under certain conditions the RPM database used by yum will become corrupt. Here is how to resolve this issue. You may see an error such as “Warning: RPMDB altered outside of yum” or “error: rpmdbNextIterator”

1. Take a backup FIRST, before trying to have rpm repair the database.

cd /var/lib
tar zcvf /var/preserve/rpmdb-[today's date].tar.gz rpm

Verify integrity with

cd /var/lib/rpm
rm -f __db*      # to avoid stale locks
/usr/lib/rpm/rpmdb_verify Packages

Next run the following:

mv Packages Packages.orig
/usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load Packages
/usr/lib/rpm/rpmdb_verify Packages
rpm -qa

Finally rebuild the database:


rpm -vv --rebuilddb

for the error :


error: rpmdbNextIterator

run:


mv /var/lib/rpm/Pubkeys /var/lib/rpm/Pubkeys.backup
rpm --rebuilddb -vv to recreate the index.

from : https://bugzilla.redhat.com/show_bug.cgi?id=108915

reference : http://kbase.redhat.com/faq/docs/DOC-6904#

Setting up yum for end-of-life CentOS 4 VPS

CentOS 4 is no longer supported by the developers and we do not recommend you install it. If you have a special case which requires CentOS 4, you will find that yum will not update or perform installs because the repository URL’s are no longer valid.

To make yum work with vault.centos.org, edit your :

/etc/yum.repos.d/CentOS-Base.repo

to have these lines:


[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://vault.centos.org/4.9/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1
protect=1

#released updates
[update]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://vault.centos.org/4.9/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1
protect=1

yum update, yum install, etc. will now work.

How do I upgrade php on a VPS?

Question:

The php version on my VPS is out of date. How do I update it?

Answer:

Using the OS vendors normal update command can get you some updates (but perhaps not what you want – see below). For example on RedHat/CentOS run:

yum update php

However usually the OS vendors versions are not the latest. The update them to patch security issues but many times are far out of date from what you may require.

To update RedHat/CentOS to a newer php run these commands:


yum erase php-pdo php-xml php-mysql php php-common php-cli php-gd php-mbstring php-devel

yum install php53-pdo php53-xml php53-mysql php53 php53-common php53-cli php53-gd php53-mbstring

/sbin/service httpd restart

A note:

These are “unofficial” RPM’s as RedHat only official supports a particular (semi-old) version and backports security fixes to it – good for large corporate users but not so great for active developers). However the RPMS’s above are widely used in the community and most developers view them as trustworthy (just important to note that they are not actually from RedHat).