Why are outdated packages installed by yum on CentOS? (specifically PHP 5.1) How to fix?

Solution 1:

CentOS is a DERIVATIVE of the very conservative Red Hat Enterprise Linux, so package updates will generally be delayed even further than RHEL. Packages in either distribution are going to be a little older.

If you're running CentOS 5, you ought to try CentOS 6 to see if it suits your needs.

If you need something a little more cutting-edge than CentOS 6, you should look into Fedora.

Follow-up: CentOS has been brought "in-house", and is more tightly integrated. Newer CentOS releases will see the benefits of a tighter release cycle, but for older releases this answer will still hold true.

Solution 2:

They're not outdated; they're the latest that CentOS 5 has in its repositories.

Red Hat (and Ubuntu for that matter) never, ever publish a new major version of software into their package repositories for a given OS version, for the sake of stability - you don't want to run an upgrade and suddenly have your config not work.

Instead, they backport security fixes and important bugfixes into the version of the software that was 'stable' when the OS was released, avoiding the introduction of new features (and their bugs).

Since you're on CentOS 5, the official repositories have some fairly old versions of stuff. But fear not - you can probably easily find a third party repository with the versions of software that you need.

Or, why not upgrade to 6?

Solution 3:

I'd say uninstall CentOS and install Ubuntu, if that's what you want to use. But it must be an older version of CentOS you use. CentOS 6.2 uses PHP 5.3 and MySQL 5.1.

You can use Remi repository to get newer versions of Apache/PHP/MySQL

And you don't make your CentOS machine work more like Ubuntu, because it is not Ubuntu. It's like saying "How do I make my Chrysler drive more like a Ford".


Updated response:

I got some down votes on this, so I think my intentions has been misunderstood, let me try to correct that.

I have set up a VPS in our environment and installed the packages, so I should be where you are at right now:

[root@centos5 /]# cat /etc/issue
CentOS release 5.7 (Final)
Kernel \r on an \m

[root@centos5 /]# rpm -qa |grep php
php-common-5.1.6-27.el5_7.4
php-mysql-5.1.6-27.el5_7.4
php-cli-5.1.6-27.el5_7.4
php-pdo-5.1.6-27.el5_7.4
php-5.1.6-27.el5_7.4

In my first response, I assumed you wanted the latest releases, then you should use the Remi repository as I have stated above. However, if the PHP 5.3 version within centOS is fine (5.3.3) then read on.

When trying to install php53 it complains that there is a conflict, since this package will cover the same things as the PHP 5.1 package. To solve this you need to remove all PHP related packages to begin with:

[root@centos5 /]# yum remove php*
[root@centos5 /]# rpm -qa |grep php
[root@centos5 /]# 

Next thing you do is to install the equivalent packages with php53:

[root@centos5 /]# yum install php53 php53-cli php53-mysql
[root@centos5 /]# rpm -qa |grep php
php53-common-5.3.3-1.el5_7.5
php53-cli-5.3.3-1.el5_7.5
php53-pdo-5.3.3-1.el5_7.5
php53-5.3.3-1.el5_7.5
php53-mysql-5.3.3-1.el5_7.5

So, PHP was quite easy. But MySQL is another story, since MySQL 5.0 is the only MySQL in the default CentOS repositories. I run the 64 bit version of CentOS, if you do not you need adjust the following to fit 32 bit instead.

There are several ways of doing this but I'm gonna go with the Remi repository. It's been around for years and maintaining is easier with a repo than using plain RPM files.

Remi requires the EPEL repository so start by installing that:

[root@centos5 /]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.lvLBMJ: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

Next, you install the Remi repo RPM

[root@centos5 /]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
warning: /var/tmp/rpm-xfer.ztjinG: Header V3 DSA signature: NOKEY, key ID 00f97f56
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]

Next you remove the current MySQL server (otherwise you will get conflicts when trying to install the new one).. NOTE! If you have databases on there, make a backup before doing this!

[root@centos5 /]# yum remove mysql*

Then you can go on and install the MySQL from the Remi repository:

[root@centos5 /]# yum --enablerepo=remi install mysql.x86_64 mysql-server.x86_64

Now when you try to start MySQL it may fail because the old mysql left some things behind, and this can be kind of painful to get rid of. In my case here I needed to remove some things to get it working. These did it for me:

# rm -rf /usr/share/mysql
# rm -rf /var/lib/mysql
# yum --enablerepo=remi reinstall mysql-libs
# /usr/libexec/mysqld --skip-grant &
# mysql_install_db
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start