How to install PHP on Centos

PHP Installation on Centos 7 



PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

Please follow below given steps to install PHP in Centos.
Please login as a root or use sudo user.

Step1:- Using yum command. You can install php using yum. it will install from centos repository.
 yum install php
 But it will install php version 5 or available in  Centos repo.

 If you want to install PHP 7 then follow below steps.

Step1:- install and enable EPEL and Remi repository on your CentOS 7 system with the commands below.
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

Step2:- Next we install yum-utils, It can be used for managing (enabling or disabling) yum repositories as well as packages without any manual configuration and so much more.

 yum install yum-utils

Step3:- One of the programs provided by yum-utils is yum-config-manager, which you can use to enable Remi repository as the default repository for installing different PHP versions as shown.

If you want to install PHP 7.0 on CentOS 7,  Then execute below command.
 yum-config-manager --enable remi-php70
OR
If you want to install PHP 7.1 on CentOS 7,  Then execute below command.
 yum-config-manager --enable remi-php71
OR
If you want to install PHP 7.2 on CentOS 7,  Then execute below command.
 yum-config-manager --enable remi-php72
OR
If you want to install PHP 7.3 on CentOS 7,  Then execute below command.
 yum-config-manager --enable remi-php73

Step4:- Now install PHP 7 with all necessary modules with the command below.
 yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo 

Now you can check the installed version of PHP on your system.
 php -V

That's It . Thank You.

Post a Comment

0 Comments