Loading...
Uncategorized

How to Install php7.X in Centos 7

Method 1:

  • Use this command to install EPEL yum repository on your system
sudo yum install epel-release
  • Install the Remi repository.
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
  • To Install PHP from yum repositories. Use one of the following commands to install PHP 7.4 or PHP 7.3 or PHP 7.2 or PHP 7.1 on your system based on your requirements.
    Install PHP 7.4
     yum --enablerepo=remi-php74 install php

         Install PHP 7.3

     yum --enablerepo=remi-php73 install php

        Install PHP 7.2

     yum --enablerepo=remi-php72 install php

        Install PHP 7.1

    yum --enablerepo=remi-php71 install php

 We have installed the latest version of PHP 7.4 on my system.
And to check the PHP version.

php -v

  • Install additional PHP modules based on your application requirements
    For PHP 7.4
yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

 For PHP 7.3

yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

 For PHP 7.2

yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

 For PHP 7.1

yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

Method 2

1)      Install epel release and yum utils

yum install epel-release yum-utils –y

2)      To install the Remi repository for CentOS 7, run:

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

3)      We’ll install PHP 7.4, which is currently the most updated stable version of PHP.

 Based on your requirement, configure the PHP 7.x repository

To configure PHP 7.1 repository, use the below command,

[root@webnoidschools ~]# yum-config-manager --enable remi-php71

To configure PHP 7.2 repository, use below command,

[root@webnoidschools ~]# yum-config-manager --enable remi-php72

To configure PHP 7.3 repository, use below command

[root@webnoidschools ~]# yum-config-manager --enable remi-php73

To configure PHP 7.4 repository, use below command

[root@webnoidschools ~]# yum-config-manager --enable remi-php74

4)      The following command will install all the required packages to get PHP 7.4

sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql  php-mysqlnd php-fpm  -y

5)      To confirm that PHP is available as your chosen version, run:

php –version

6)      To search all PHP modules use the below command:

[root@Webnoidschools ~]#  yum search php | more

To Verify PHP Installation.

I am assuming Apache web Server is installed on your system, start its service using the below systemctl command

[root@webnoidschools ~]# systemctl start httpd

Now create a info.php file under /var/www/html with following contents,

[root@webnoidschools ~]# cd /var/www/html/

[root@webnoidschools html]# vi info.php
<?php
phpinfo();
?>

Open the web browser and type the ip of your server followed by info.php,

http://Server IP Address/info.php

Leave a Reply

Your email address will not be published. Required fields are marked *