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