Install PHP on CentOS
Install PHP on CentOS 7

You can get simple and understandable steps to install PHP on CentOS. Before we move into the installation, let’s have a brief look on PHP.

What is this PHP? Let me tell you. PHP means Hypertext Processor, which is a programming language for web development. You can create dynamic web page contents or images as you wish.

CentOS is a Community Enterprise Operating System. It is an open-source platform for non-productive developmental work. For production concern, those works can be migrated to RHEL (Payable) Linux distribution platform.

For now, we can focus on PHP 5.6, which will be the basic version widely used. Later will explain to you how to install any version of PHP on CentOS.

Let’s have a quick look on PHP 5.6 features and versions available.

Reduced Memory, due to the reuse of php://input. Numeric, String and constant have scalar expression. A constant array can use constant keywords. PHP 5.6 can be used for command-line scripting. Graphical user interface application can also be used by clients. It has advanced protection patches.

By default PHP 5.4 version is available in CentOS software package repositories. But we can update packages with latest versions of PHP.

Complete Version list of PHP -> PHP 1.0 , PHP 2.0, PHP 3.0, PHP 4.0, PHP 4.1, PHP 4.2, PHP 4.3, PHP 4.4, PHP 5.0, PHP 5.1, PHP 5.2, PHP , PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 6.X, PHP 7.0, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, PHP 8.0.

Before Installation:

Please make sure that remi:repo file was enable. i.e Enable=1 (inside remi:repo file) .

Next point is to check the package was having required version for installation.

Here We Go:

Let’s start the installation. The first click on the browser window, you could see the terminal and start executing the below commands in the mentioned order.

Type the below command to install the rpm release packages. This will help you to install the packages of PHP version you wish to install.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Next important step will be the utilities. This utilities enhancement will integrate with yum, to adopt the default features. This will provide user with advanced package management options. So that no manual configuration required for enabling and disabling the packages. For this, install utils command given below.

yum install yum-utils

Enter ‘y’ after the utils command execution completed.

Next step will be the most important program provided by utilities is configuration manager, through which the activation of ‘Remi repository’ will happen. This will be the default manipulating repository settings provided by utilities. This will help us to install any version of PHP.

In the end of command you can see two digits, which represents the version number.

Eg: 56 for PHP 5.6 , 74 for PHP 7.4

Below command will enable you the selected version.

yum-config-manager –enable remi-php56

We are going to install the PHP of required version. You can use any extension from the list given below with respect to your library files.

yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

Finally, To make sure that you have enabled correct version, use below command and check the version.

php -v

After Installation of PHP:

To check the installation, First you can restart your apache package, using below command.

service httpd restart

Here you go…!! We successfully installed the PHP on CentOS.

You can now start working on PHP!!

If you don’t have installed phpMyAdmin on CentOS 7 you can install one by following These Instructions

Today, we learned about “What is PHP”, “Basics of PHP and CentOS” , “Versions available in PHP”, “Steps to be followed before installing PHP”, “How to install PHP in CentOS?” , “Steps to be followed after installing PHP” and finally “How to validated PHP”.

Hope it helped you in an easy way to install PHP with more understanding. Please let us know in the comment section if you have any concern.

You can also share with your friends, who need to install PHP.