How to Upgrade PHP 5.3.X to 5.4.X or 5.5.X on Centos
Edit Article

  • 1 Editor

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).

PREREQUISITES

  1. You will need proper knowledge of how to use Putty or Terminal.
  2. You will need to have grip over the basic SSH commands.
  3. 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.

Step-1:


You need to login to your server using Command Line (Terminal or Putty)/


Step-2:


Now you need to add the two repositories; EPEL and Remi on your system.


On Centos 6.x 32-bit

1

On Centos 6.x x86_64 (64-bit)

2

Here is a screenshot of what you will see:

3

Step-3:


Now you must enable the repository (Remi) that you just added. Open the repository by going to


/etc/yum.repos.d/remi.repo


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:

4

Step-4:


Find the line that say Enabled = 0 and edit it to Enabled = 1:


4.a – Update to PHP 5.4, in [remi] section:

5

4.b – Update to PHP 5.5, in [remi-php55] section

6

4.c – Bonus – Update to PHP 5.6 (beta version), in [remi-php56] section:

7

Once you’re through with making all the changes, save them and exit the edior.


Step-5:


Now you will need to update yum by:

9
8

Step-6:


Once you are done, you can enter this command to check if all went well:

10

The example here gives:


PHP 5.4.28

11

PHP 5.5.124

12

PHP 5.6.0 Beta 2

13

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.


Step-1:


You need to make a backup of the php.conf file:

14

Step-2:


Now, you will edit the php.conf file:

15

Step-3:


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.


Step-4:


And now you will start the httpd (Apache) service again:

16

You will now need to upgrade MySQL by using this command:

17

That is it. You’re all done. Enjoy.

Article Tools

Did this article help you?

YesNo

Become
an Author!

Write an Article