How to Update to PHP 7.4 from PHP 7.x on CentOS 7 How to Update to PHP 7.4 from PHP 7.x on CentOS 7 apache apache

How to Update to PHP 7.4 from PHP 7.x on CentOS 7


READ FIRST -- IMPORTANT !!!Get a complete backup snapshot of your server before you complete these update steps

  1. First thing you should do is do any core OS updates and package updates.

    yum update -y

  2. Check which version of PHP you are currently running.

    php -v

  3. Print a list to see all the PHP packages you have installed. You will need to replace all these packages in PHP 7.4. You should copy this list to a file so you can refer to it if you need to. Make a note of the version of PHP here (7x or 7-x).

    rpm -qa | grep php

    rpm -qa | grep php > php_rpm.txt

  4. Remove PHP core and all the installed PHP packages.

    yum remove "php*" -y

  5. Install the updated remi repository if it is not already installed.

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

  6. Check out a list of all available remi packages (not-required)

    yum repolist remi-safe

7. Disable PHP 7.x and enable PHP 7.4 (Replace x with sub-version of your previously installed version noted above in step 3) and install any extra packages you want / need.

yum --disablerepo=remi-php7x --enablerepo=remi-php74 install php php-pdo php-fpm php-gd php-mbstring php-mysql php-curl php-mcrypt php-json -y
  1. Check the updated PHP version.

    php -v

  2. Restart Apache to use the newly installed PHP 7.4

    systemctl restart httpd