How to update and install php 5.3 and php 5.2 CentOS webtatic repo

→ Are you a new visitor? Please visit the page guidance for new visitors ←

How to install php 5.3 and php 5.2

A few weeks ago I had a client that needed an old php version updated, normally you can easily update or install php 5.3 directly from repository, but unfortunately there are a few scripts that require an older version of php installed, this is tricky when there aren’t any sources available. Luckily I have here a source or repository, whatever you wish to call it, that can be used in such situations. In this article I’m going to show you a direct and simple way to install php 5.3 and php 5.2 directly using yum package installer.

For starters we need to install the rpm from so that we are able to install packages directly from them. For this we can run the bellow command:

  • Centos 5

  • Centos 6

Next we run the normal installation procedure, but first enable the repository by using the parameter –enablerepo=webtatic.

Of course, if we already have php already installed and we want to update its version to the latest version, we can do this in the same way:

Do keep in mind that for php 5.3 you will need to specify that you do not wish to view deprecated errors in your logs. This helps in removing the annoying errors that are usually more for informing us that the function specific is deprecated. We can do this by editing the php.ini file and changing the value:


Do not forget, after making changes to your php.ini file, you need to restart your web server.

Update PHP 5.2.17 on CentOS 5

For specially updating the php version 5.2 on centos 5 we can use the –exclude=php*5.3* parameter like so:

Or we can just add that parameter directly to the repository file:

on a new line:

Compiling PHP 5.2.17 on CentOS 6

Unfortunately the php 5.2.17 version can no longer be installed from repos, sad but that’s how it is with old versions. Well the only way here is to manually compile php. First make sure you have gcc, make and httpd-devel libxml2-devel bzip2-devel openssl-devel curl-devel gd-devel libc-client-devel libmcrypt-devel libmhash-devel mysql55-devel aspell-devel libxslt-devel installed as these are needed:

Then we start by downloading the package php-5.2.17.tar.gz :

We will now need to configure it, I’ve added –with-apxs2=/usr/sbin/apxs to add mod_php directly to apache. It should then work with your normal apache installation as long as you are only using mod_php.

The result should be similar to:

Then run the make and make install to compile it and install php on your system.

The end result would have php working on your server, bellow is a phpinfo() page:

Apache 2 and phpinfo page

Apache 2 and phpinfo page

That’s it for now, if you like it, don’t forget to share it and comment.

Request an article ←