PHP (Hypertext Preprocessor) is the most popular server-side scripting language and used in developing static and dynamic web sites. In this article, we will demonstrate on how to install latest version of PHP 7.4 on CentOS 8 and RHEL 8.

Minimum System Requirements for PHP 7.4

  • Minimal CentOS 8 / RHEL 8 OS
  • Sudo or Root Privileges
  • Basic Package Repositories
  • Internet Connection

Let’s jump into installation steps,

Step:1) Enable EPEL and Remi Repository

In the default CentOS 8 and RHEL 8 package repositories, PHP 7.2 / 7.3 is available and to install latest version of PHP 7.4, we must configure EPEL and REMI repositories, so to enable the repositories, run the following commands:

[[email protected] ~]$ sudo dnf install epel-release -y
[[email protected] ~]$ sudo dnf install -y

Once the repositories are configured and enabled, run the following dnf command to view available PHP versions,

[[email protected] ~]$ dnf module list php


As we can see in above output, PHP 7.2 is the default package from CentOS-8 AppStream repository, so in the next step, we will enable latest PHP module stream (redmi-7.4) so that when we install install PHP using dnf then it will automatically pick packages from remi-7.4 module

Step:2) Enable latest PHP Module Stream (remi-7.4)

Execute the following dnf command to enable remi-7.4 PHP module,

[[email protected] ~]$ sudo dnf module enable php:remi-7.4


Step:3) Install and Verify PHP

Now run the following dnf command to install PHP 7.4,

[[email protected] ~]$ sudo dnf install php php-cli php-common


As we can see that it is installing its dependencies like httpd and nginx, So once above packages are installed successfully, run below “php -v” command to verify installed php version,

[[email protected] ~]$ php -v


While installing PHP, php-fpm is also installed as its dependency, it will be treated as FastCGI Server, so use below command to start and enable FPM service,

[[email protected] ~]$ sudo systemctl start php-fpm
[[email protected] ~]$ sudo systemctl enable php-fpm

Step:4) Updating PHP Parameters

While using the php in different CMS (Content Management System) like WordPress, Drupal, Joomla and MediaWiki etc we might have to update default PHP parameters to improve the performance. These parameters can be alerted from its configuration file “/etc/php.ini”,

[[email protected] ~]$ sudo vi /etc/php.ini
upload_max_filesize = 32M 
post_max_size = 48M 
memory_limit = 256M 
max_execution_time = 600 
max_input_vars = 3000 
max_input_time = 1000

Save and exit the file, To make the above changes into the effect restart your web server service (httpd or nginx )

[[email protected] ~]$ sudo systemctl restart httpd

That’s all from this article, I hope these steps help you install and configure PHP 7.4 on your CentOS 8 and RHEL 8 System. Your feedback and comments are most welcome.

from Linuxtechi