CentOS 4.x : Upgrading PHP and MySQL

Disclaimer

These instructions worked for me in CentOS 4.0. It may very well work for you on Red Hat-like or other distributions. Please note that if you decide to use these instructions, you are doing so entirely at your very own discretion and that neither this site, sgowtham.com, nor its author is responsible for any/all damage – intellectual or otherwise.


This particular website and few others of my friends (Boney Legs, Karen and Tim) have been running pretty smoothly and serving contents in stunningly beautiful high definition (You don’t agree with me? Please consider changing your monitor!) for the past few months on a virtual node in linode.com. The default installation – of CentOS 4.0 – had almost everything I (we) needed to run most of our stuff. However, it was missing a thing or two – most important ones being the GD-Library (with JPEG Support) and the MBString extension in PHP. These missing features prevented PixelPost from (automagically) generating thumbnails and some other utilities I have been working on.

After a bit of Google!ing around, it wasn’t difficult to find an RPM for MBString (although I probably could have done it with yum). Using yum, I added the GD-Library (with JPEG Support) as well.

yum -y install php-gd

While discussing somethings with Amy, I got the urge to upgrade PHP from version 4.3.9 to the latest & greatest version 5.1.6. I edited the /etc/yum.repos.d/CentOS-Base.repo to enable centosplus section:

1
2
3
4
5
6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=1

My attempts via yum failed, resulting in the following (error) message:

yum -y update php
--> Running transaction check
--> Processing Dependency: php = 4.3.9-3.22.9 for package: php-pear
--> Finished Dependency Resolution
[MORE STUFF]
Error: Missing Dependency: php = 4.3.9-3.22.9 is needed by package php-pear


I figured I would update php-pear first and then try updating php. That didn’t work either and here’s what I did to get around this issue:

  1. Remove php-pear

    rpm -e php-pear

    will not work. There are a bunch of other packages that need to be removed as well. As such, one needs to remove php-pear without removing any other packages:

    rpm -e --nodeps php-pear

    does the trick.

  2. Update php

    yum -y update php

    takes some time but does complete successfully.

  3. Install php-pear

    yum -y install php-pear

    accomplished this part.


While I was at it, I figured I would update mysql as well. yum -y update mysql took some time but did finish well resulting in version 5.0.54 (from v4.1.20). Once all this is done, there were few more steps I had to do:

  1. cd /etc/
    mv my.cnf.rpmnew my.cnf
  2. Appropriately edit /etc/php.ini
  3. Restart MySQL server:
    /etc/init.d/mysqld restart
  4. Restart Apache:
    /etc/init.d/httpd restart


PHP 4.3.9 and 5.1.6

PHP: Old and New versions


I randomly accessed some pages from each of the websites that run on this server and ran some more scripts to make sure everything worked the way it should. So far, I haven’t found any issues/bugs.

One Reply to “CentOS 4.x : Upgrading PHP and MySQL”

Leave a Reply to Dave Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.