This guide let you learn how install the latest PHP version 7.4 on your CentOS system or your CentOS server on any VPS or any Dedicated hosting and configure it with Apache and Nginx.
The latest PHP 7.4.3 version is released on February 20th, 2020. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.
This installation is tested on Hostinger. This set up will work on all Linux servers.
Step 1: Getting Started
Make sure your CentOS server is having the latest packages by running the following command.
yum update && yum upgrade
This will update the package index and update the installed packages to the latest version.
Step 2: Add EPEL and REMI repositories
Add the EPEL and REMI repositories which has PHP 7.4 package and other required PHP extensions.
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Once you have added these repositories you can install PHP 7.4.
Step 3: Install PHP 7.4
Execute the following command to install dnf. Then you can install PHP.
dnf -y install dnf-utils
Enable php:remi-7.4 module to install PHP 7.4.
dnf module install php:remi-7.4
After the installation has completed, you can confirm the installation using the following command
PHP 7.4.3 (cli) (built: Feb 18 2020 11:53:05) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
Step 4: Install PHP 7.4 Extensions
Now you can install some commonly used php-extensions for WordPress with the following command.
yum install -y php-devel php-opcache php-pear php-cli php-process php-json php-pdo php-gd php-common php-fpm php-mysqlnd php-bcmath php-xml php-mbstring
Restart PHP 7.4 FPM
Once you have updated your PHP FPM settings you need to restart it to apply the changes.
systemctl restart php-fpm
Now you are having PHP 7.4 Installed and configured.
Now you have learned how to install PHP 7.4 on your CentOS server.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.