How To Install Custom PHP Version On CentOS 5/6/7 ?

How To Install Custom PHP Version On CentOS 5/6/7 ?

When It comes to the LAMP environment sometimes it is required to install a custom version of PHP on your server because every repository has its own default version Package. In my previous tutorial (How to install PHP and How to set up LAMP stack) we used yum.

This article, we will compile our own PHP version according to need and by the end of this article, you will b able install any version of PHP(5.6, 5.7 or 7).

Scenario: My Server IP is
Custom PHP Version: PHP 5.6

Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

Step 1: Create a Directory And Installing Development Tools

First, you need to log in and move to your home directory and create a directory for downloading PHP.

Step2: Download PHP version

Now identify the version you want to install from the website
click on .tar.gz link for your desired PHP version now right click and copy link address.

How To Install Custom PHP Version On CentOS 5/6/7 ?

Now Run the Following command on Terminal

Your downloaded file will be by the name mirror and don’t forget to check that file is completely by using this command

Step 3: Untar the files

As we have downloaded our desired version in tar.gz so we need to decompress it and rename the uncompressed directory by some simple name for our ease.

Step 4: Setting Up Installation Directory

To process further we need a directory to install PHP. In my case, I am installing in /user/local/php56 but you can change this location to you home directory or any other directory you want.

Step 5: Installing PHP

Now it is a simple and we need to compile this PHP on our server by these simple commands.

Step 6: Setting Up Path for PHP

Now to set your custom /usr/local/bin/ directory to your user’s PATH you need to edit your  /etc/profile and enter the following:

Run the following command to update your .bash_profile in the current session and login:

Step 7: Check Your Installation

As you have successfully installed our custom PHP version, we need to verify its version and location of installation

Output Window will be like:

Also, check which version of PHP your shell is using:

Output Window:

Watch Video:

YouTube Link

You may also Like

  1. How To Install PHP using YUM
  2. How To Set Up LAMP Environment With Apache MySql And PHP: Part-1