Installing the latest PHP (5.4.23 / 5.5.7) on CentOS/RHEL 1

Method 1 – Remi Repo

The Remi Repository (famillecollet.com) maintains the newest PHP for CentOS, RHEL, etc. And by newest, I mean newer than all other major repos.

All you need to do is install PHP with Remi enabled. As of writing this article, Remi has 5.4.23 for CentOS, RHEL, etc. If you want even newer version or any other custom version, see method #2.

1
yum install php

If you are also looking for how to install remi on your system, check out this guide from rackspace.

If you are using Remi, I suggest you use yum-versionlock plugin to ensure that you stay in the right version.

Method 2 – Compile your own PHP

Download

You can download the version you want from PHP directly. As of writing the latest stable available is 5.5.7.

Dev Tools

If you don’t already have this, you can download necessary development tools via group install.

1
yum groupinstall "Development Tools"

Required Libraries

You’ll also need bunch of libraries to compile PHP. The following is a mere sample list. You may need to adjust depending on additional modules you are installing.

2
3
4
5
yum install libxml2-devel httpd-devel libXpm-devel gmp-devel libicu-devel \
    t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel \
    libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel \
    libtidy-devel libxslt-devel

Another common library often used is mcrypt (libmcrypt-devel), but that’s available under rpmforge and not the base.

Compiling

Once all the requirements are set, actual compilation is fairly simple.

Extract the php you downloaded earlier and enter directory.

6
7
tar jxf php-5.4.*.tar.bz2
cd php-5.4.23

Configure the PHP with stuff you want enabled.

8
./configure --enable-zip --[etc. This list can get pretty long...]

You can see a full list of PHP configuration options here.

Then finalize with build.

9
10
make 
make install

Now you have php 5.4.* on your Centos 6 / RHEL

 

One comment on “Installing the latest PHP (5.4.23 / 5.5.7) on CentOS/RHEL

  1. Reply william Oct 23,2017 12:41 pm

    Thanks!!!

Leave a Reply to william Cancel Reply