PHP 7.4 is the latest stable release of PHP. May of popular yum repositories is providing rpm packages for PHP 7. This article is using Remi and EPEL yum repositories for installing the required packages on your system. This article will help you to install PHP 7.4, PHP 7.3, PHP 7.2, PHP 7.1 on CentOS & Redhat 7 servers. This tutorial has been tested with CentOS Linux release 7.4.1708.

Advertisement

Setup Yum Repository

First of all, you need to enable Remi and EPEL yum repositories on your system. Use the following command to install EPEL repository on your CentOS and Red Hat 7/6 systems

Use this command to install EPEL yum repository on your system

sudo yum install epel-release

and now execute one of the following commands as per your operating system version to install the Remi repository.

sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Install PHP 7 on CentOS

Your system is prepared for the PHP installation 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

I have installed the latest version PHP 7.4 on my system. Now running the following command to check the current active PHP version on my system.

php -v

PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Install PHP Modules

You may also need to install additional PHP modules based on your application requirements. The below command will install some more useful PHP modules.

### 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

You can run the following command to search other available PHP modules under configured yum repositories. Below example command search for all modules for PHP 7.4.

yum --enablerepo=remi-php73 search php | grep php73


 * remi-php74: repo1.ash.innoscale.net
php74.x86_64 : Package that installs PHP 7.4
php74-php.x86_64 : PHP scripting language for creating dynamic web sites
php74-php-bcmath.x86_64 : A module for PHP applications for using the bcmath
php74-php-brotli.x86_64 : Brotli Extension for PHP
php74-php-cli.x86_64 : Command-line interface for PHP
php74-php-common.x86_64 : Common files for PHP
php74-php-componere.x86_64 : Composing PHP classes at runtime
php74-php-dba.x86_64 : A database abstraction layer module for PHP applications
php74-php-dbg.x86_64 : The interactive PHP debugger
php74-php-devel.x86_64 : Files needed for building PHP extensions
php74-php-embedded.x86_64 : PHP library for embedding in applications
php74-php-enchant.x86_64 : Enchant spelling extension for PHP applications
php74-php-fpm.x86_64 : PHP FastCGI Process Manager
php74-php-gd.x86_64 : A module for PHP applications for using the gd graphics
php74-php-gmp.x86_64 : A module for PHP applications for using the GNU MP
php74-php-imap.x86_64 : A module for PHP applications that use IMAP
php74-php-intl.x86_64 : Internationalization extension for PHP applications
php74-php-json.x86_64 : JavaScript Object Notation extension for PHP
...
...
Share.

17 Comments

  1. # yum –enablerepo=remi-php73 install php
    DigitalOcean Agent 119 kB/s | 3.3 kB 00:00
    Package php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 is already installed.
    Dependencies resolved.
    Nothing to do.
    Complete!

    i am unable to update my php. i dont know what is wrong. Even if i use php74 repo, it still says
    “”php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 is already installed.
    Dependencies resolved.
    Nothing to do.””

    what am i doing wrong ?

  2. I lleave a response whenever I appreciate a pot on a site
    or if I have something to contribute to the discussion. Usually it is caused
    by the fire communicated in the post I read. And after this post How To Install PHP 7.4, 7.3 & 7.2 on CentOS 7 – TecAdmin. I was moved eenough to drop a thought 🙂 I do have 2 questions foor you if it’s
    allright. Is it simply me or does it give the imprewsion like some of the comments appear aas if they are written by brain dead folks?
    😛 And, if you are wrjting on additional places, I would like to keep up with you.
    Would you list the complete urls of your sbared ssites like your linkedin profile,
    Facebook page orr twitter feed?

  3. DANIEL MARQUES CUNHA on

    Thank you man, I needed to do that using the ansible and this article helped me to have some ideas of how to do it.

  4. Hi,

    I successfully installed php7.2 on my RHEL7. Now I need to install zend modules, does anyone knows how to do that? Baiscally l want following:

    Thanks

    [root@webintranet ~]# php -v
    PHP 5.3.14 (cli) (built: Dec 10 2013 10:53:17)
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Zend Extension Manager v5.1, Copyright (c) 2003-2010, by Zend Technologies
    – with Zend Data Cache v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]
    – with Zend Download Server v1.5.0, Copyright (c) 1998-2010 Zend Technologies Ltd., by Zend Technologies [loaded] [licensed] [disabled]
    – with Zend Job Queue v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [not licensed] [disabled]
    – with Zend Session Clustering v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]
    – with Zend Utils v1.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [enabled]
    – with Zend Optimizer+ v4.1, Copyright (c) 1999-2010, by Zend Technologies [loaded] [licensed] [disabled]
    – with Zend Code Tracing v1.0, Copyright (c) 2009-2010, by Zend Technologies [loaded] [not licensed] [disabled]
    – with Zend Page Cache v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]

  5. Hi, first of all, thanks for your post. I’ve tried to update to php 7.3 but there is an error with the packet libargon2.so.0()(64bit). After a research on the Internet, it seems there are some packets not uptated yet for CentOS: https://blog.remirepo.net/pages/PECL-extensions-RPM-status
    So I don’t know if there is a way to full update to PHP 7.3 with no errors. THX!!

    Error: Paquete: php-7.3.1-1.el7.remi.x86_64 (remi-php73)
    Necesita: libargon2.so.0()(64bit)
    Error: Paquete: php-cli-7.3.1-1.el7.remi.x86_64 (remi-php73)
    Necesita: libargon2.so.0()(64bit)
    Error: Paquete: php-fpm-7.3.1-1.el7.remi.x86_64 (remi-php73)
    Necesita: libargon2.so.0()(64bit)

  6. I have PHP 5.4 , PHP 5.5, PHP, 5.6 installed and need to leave them installed. When I try to install php70w I get the error, “php70w-common-7.0.0-1.w7.x86_64 conflicts php-common < 5.5.0". Do your directions only work if we uninstall previous versions of PHP? If so, what should I do to make it work where multiple versions of PHP need to be installed?

    • Praveen Dewangan on

      Hi Charles,

      You can manage multiple PHP versions using PHPBrew. It is also useful to switch between different versions of PHP.

Leave A Reply

Exit mobile version