Select Page

A recursive acronym for PHP HyperText Preprocessor, PHP is an open-source and widely used server-side scripting language for developing static and dynamic websites. It is the core of most blogging systems such as WordPress, Drupal, and Magento.

PHP 7.x came into the picture in 2015 with the release of PHP 7.0.0. This has seen the release of several versions since then.

At the time of writing this tutorial, the only supported release is PHP 7.4 in the 7 series. The latest PHP 8 comes with tons of new features, functions, and deprecations as compared to PHP 7.

In this guide, we will focus on how to install PHP 7.4 on Rocky Linux 8.

The first step will be to install PHP.

Fortunately, the Rocky Linux AppStream repositories include PHP versions beginning with PHP 7.2, which is enabled by default.
Run the command to receive a list of all the hosted PHP modules.

$ sudo dnf module list php

To get PHP 7.4, you must first enable the module as instructed.

$ sudo dnf module enable php:7.4

NOTE: Simply replace 7.4 with the preferred version to enable a different module.
To enable 7.3, for example, type:

$ sudo dnf module enable php:7.3

Install PHP and any associated PHP extensions (php-extension name) as directed once PHP is installed.

$ sudo dnf install php php-cli php-gd php-curl php-zip php-mbstring

Verify the PHP version installed after the installation is complete.

$ php -v