This tutorial is best suited for beginners who want to upgrade the PHP version from 5.3.x to 5.4.x or 5.5.x on CentOS by using the yum command line interface. This tutorial also offers valid pictures where needed so that you may have a better idea of what you’re doing and whether you’re doing it right or not. Just to add to your information, most of the default LAMP stacks that you install already come with V5.3.x as its default one because it is known to be the most suitable one among all the versions. A few months ago many users wanted the V5.4.x because it was the newest stable version. Other than this version people also went for v5.5.x which is known as the bleeding edge newest version.
Most ask this important question of whether to upgrade to the latest version of PHP or not? Well, installing the newer version is not always the right answer. There is not obligation if the newer version will be faster or better. But the plus point of a newer version is that it provides with new enhancements, features and improvements that the old version was unable to offer. Even with all that new stuff it is not better than the older version.
If you’re consulting just this blog then you will get to know that PHP 5.3 is a little faster than the 5.4 and 5.5 versions, about 0.7 times faster than the 5.4 version. The good about version 5.4 and onwards is that their memory consumption dropped significantly. A benchmark was conducted that gave us the result that version 5.4 and version 5.5 are the same regarding speed and memory consumption. So it is totally up to you which version you want to upgrade to.
UPGRADING PHP ON CENTOS
The VPS that I used to make this tutorial was on a CentOS 6.5x86 (32-bit).
- You will need proper knowledge of how to use Putty or Terminal.
- You will need to have grip over the basic SSH commands.
- You must have LAMP stack installed on your VPS. If not the whole stack then PHP 5.3 and Apache should at least be installed.
You need to login to your server using Command Line (Terminal or Putty)/
Now you need to add the two repositories; EPEL and Remi on your system.
On Centos 6.x 32-bit
On Centos 6.x x86_64 (64-bit)
Here is a screenshot of what you will see:
Now you must enable the repository (Remi) that you just added. Open the repository by going to
This repository file and now you will need to add a text editor which you like the best. In this tutorial I will be using the Nano text editor:
Find the line that say Enabled = 0 and edit it to Enabled = 1:
4.a – Update to PHP 5.4, in [remi] section:
4.b – Update to PHP 5.5, in [remi-php55] section
4.c – Bonus – Update to PHP 5.6 (beta version), in [remi-php56] section:
Once you’re through with making all the changes, save them and exit the edior.
Now you will need to update yum by:
Once you are done, you can enter this command to check if all went well:
The example here gives:
PHP 5.6.0 Beta 2
You can now test your script by running it on your browser. Hopefully everything will run accordingly well.
MESS PREVENTIVE MEASURES
Now to save your time and effort you might need to edit the old httpd.conf if the script did not run according to plan.
You need to make a backup of the php.conf file:
Now, you will edit the php.conf file:
Now you must go through the whole file and find every line that has php_ in it. Once found simply add # or jut remove it. There is at least one line per domain. Once you have found them all, remove every single one of them and then save the file and exit.
And now you will start the httpd (Apache) service again:
You will now need to upgrade MySQL by using this command:
That is it. You’re all done. Enjoy.