How to Install/Update PHP to 7.4 on CentOS 7

Updated on October 14, 2021

Recently while looking onto my client’s WordPress dashboard, found a notification that the PHP version might be vulnerable and needs an update as shown below for security reasons. I’m running PHP 7.0 on CentOS 7 which was installed using Remi repo. Here is the step-by-step guide to update PHP to the 7.4 version.

WordPress notification on PHP version

Step 1: First and foremost, get the complete backup of your server and the website before proceeding further.

Step 2: Update your server

# yum install epel-release yum-utils -y
# yum update -y

Step 3: Check the version of the PHP that is currently running.

# php -v

Step 4: List all the PHP packages you have installed into a file, so you can refer to it to install all those packages in PHP 7.4

# rpm -qa | grep php > php_rpm.txt

Step 5: Remove all the installed PHP packages

# yum remove "php*" -y

Step 6: Install the updated Remi repository if it is not already installed.

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

Step 7: Enable the PHP 7.4 repository, install the core and required PHP packages. You can also refer to step 4 for the previously required packages.

# yum --enablerepo=remi-php74 install php php-pdo php-fpm php-gd php-mbstring php-mysql php-curl php-mcrypt php-json -y

Step 8: Check the updated PHP version.

# php -v
PHP 7.4.24 (cli) (built: Sep 21 2021 11:23:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Step 9: Restart Apache to use the newly installed PHP 7.4

# systemctl restart httpd

Was this article helpful?

Related Articles

Comments Leave a Comment

  1. In 7th Step Im getting this error!

    Error: php74-common conflicts with php-common-5.4.16-48.el7.x86_64
    Error: Package: php-json-7.4.32-1.el7.remi.x86_64 (remi-php74)
    Requires: php-common(x86-64) = 7.4.32-1.el7.remi
    Installing: php-common-5.4.16-48.el7.x86_64 (base)
    php-common(x86-64) = 5.4.16-48.el7
    Available: php74-common-7.4.29-1.el7.ius.x86_64 (ius)
    php-common(x86-64) = 7.4.29-1.el7.ius
    Available: php74-common-7.4.30-1.el7.ius.x86_64 (ius)
    php-common(x86-64) = 7.4.30-1.el7.ius
    Available: php74-common-7.4.32-1.el7.ius.x86_64 (ius)
    php-common(x86-64) = 7.4.32-1.el7.ius
    Error: Package: php-json-7.4.32-1.el7.remi.x86_64 (remi-php74)
    Requires: php-common(x86-64) = 7.4.32-1.el7.remi
    Installing: php-common-5.4.16-48.el7.x86_64 (base)
    php-common(x86-64) = 5.4.16-48.el7
    Available: php74-common-7.4.29-1.el7.ius.x86_64 (ius)
    php-common(x86-64) = 7.4.29-1.el7.ius
    Available: php74-common-7.4.30-1.el7.ius.x86_64 (ius)
    php-common(x86-64) = 7.4.30-1.el7.ius
    Installing: php74-common-7.4.32-1.el7.ius.x86_64 (ius)
    php-common(x86-64) = 7.4.32-1.el7.ius
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest
    [root@mail ~]#

    Please let me know how to resolve it. Thanks

  2. after all steps in 8-th step : bash: /bin/php: No such file or directory i recieved this massage

Leave a Comment