How to Install PHP 5.4, PHP 5.5 or PHP 5.6 on CentOS 6

The current version of PHP in the CentOS 6 official repositories is PHP 5.3, which has reached its end of life and is no longer maintained (in terms of bug fixes and critical security updates) by the developers. You may be exposed to unpatched security vulnerabilities if you are still using it.

Therefore it is recommended for you to upgrade or install a latest supported stable version of PHP 5.4 or PHP 5.6 on a CentOS 6 Linux distribution as soon as possible.

Install EPEL and Remi Repository

1. To install latest stable version of PHP, you need to add EPEL and Remi repository to your CentOS 6 distribution using the following commands as root user.

# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm remi-release-6.rpm
Install EPEL and Remi Repo

Install EPEL and Remi Repo

Install Yum-Utils to Manage Repository

2. Install yum-utils, a collection of utilities that integrate with yum to extend its native features in several ways, thus making it more powerful and easier to use.

The package yum-utils used to enable or disable packages on the fly without any manual configuration.

# yum install yum-utils
Install Yum Utils

Install Yum Utils

Install PHP 5.4, PHP 5.5 or PHP 5.6 on CentOS 6

3. Once EPEL, Remi and yum-utils has been installed, you can now move ahead to install PHP 5.4, PHP 5.5 or PHP 5.6 with all required modules on CentOS 6 distribution by enabling remi repository using yum-config-manager command as shown.

# yum-config-manager --enable remi-php54    [Intall PHP 5.4]
# yum-config-manager --enable remi-php55    [Intall PHP 5.5]
# yum-config-manager --enable remi-php56    [Intall PHP 5.6]

4. Once you’ve enabled selected version of PHP, you can install PHP (in my case I have chosen PHP 5.6) with all needed modules as shown.

# yum-config-manager --enable remi-php56    [Intall PHP 5.6]
# yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo 
Install PHP 5.6 in CentOS 6

Install PHP 5.6 in CentOS 6

If you want to downgrade PHP version for any reason, you will need to remove existing PHP version and then reinstall the new PHP with modules you want.

Finally, do not forget to check out these useful PHP articles:

  1. How to Use and Execute PHP Codes in Linux Command Line
  2. How to Find MySQL, PHP and Apache Configuration Files
  3. How to Test PHP MySQL Database Connection Using Script
  4. How to Run PHP Script as Normal User with Cron

That’s all! To share any thought with us, make us of the feedback form below. Lastly, remember to always stay connected to Tecmint.com.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

12 Responses

  1. Patrick says:

    No package php available.
    No package php-mcrypt available.
    No package php-cli available.
    No package php-gd available.
    No package php-curl available.
    No package php-mysql available.
    No package php-ldap available.
    No package php-zip available.
    No package php-fileinfo available.
    ———-
    Got any other tips?

    • Ravi Saive says:

      @Patrick,

      Have you enabled EPEL and Remi Repository on the system?

      • Patrick says:

        I’m just dumb! Cpanel was managing my system and was excluding packages with PHP in the title! The nerve! “I wish I knew how to quit you!” -me to Cpanel ( ^∇^)

  2. jam says:

    Thank you very much, it worked correctly for me. Thank you.

  3. Fred Hicks says:

    Didn’t work at all. Followed the instructions to get to php 5.6, and yum remained stubbornly fixed on insisting that php 5.3.3 is the latest version and already installed.

  4. Yan D. Alaury says:

    Hi,

    I want to upgrade PHP 5.4.45-56.el6.art to PHP 5.6 and my MYSQL is 5.5.55-1659.el6.art.

    Is it dangerous to upgrade php 5.4.45 to php 5.6 without upgrading mysql?

    Thank you so much for your answer

    Yan

Leave a Reply to Fred Hicks 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.