How to Install PHP 8.4 on CentOS and Fedora: A Complete Guide

  • Last updated: Oct 30, 2024
  • Views: 86
  • Author: Admin

The PHP programming language is one of the most popular languages ​​used in web development. Today, the latest version of the PHP language is 8.4. The latest release of PHP offers many more performance improvements, new language features have been added.

If you are using CentOS or Fedora operating system and you want to install PHP 8.4 for your application, then this article will help you understand the intricacies of the installation. In this article, we will consider the steps necessary to prepare the Linux system, install the necessary dependencies, add the EPEL repository with the latest version of PHP and finally install PHP itself.

We will install PHP 8.4 on CentOS 9. Don't worry if you have another platform installed instead of CentOS, for example Fedora or OracleLinux, the installation process will be the same as on CentOS.

To avoid various problems with installing PHP on your system, you should have sudo permissions or perform all actions as root.

This article on the page is based on my many years of experience with this technology and is presented to you as a small instruction, but if you want to get acquainted with it in more detail, then I recommend you go to the official documentation on PHP.

 

Contents of the article:

  1. Updating the repository.
  2. Installing EPEL and Remi repository.
  3. View available PHP builds.
  4. Installing PHP.
  5. Checking PHP version.

 

1. Updating the repository.

Before installing php we need to update all packages to the latest version in our local repository. To update packages we use the command in the terminal:

$ sudo dnf update && sudo dnf upgrade

These commands will check all packages that are installed on the system and if the system notices that there are updates for any package, Linux will automatically install the new version of the package.


 

2. Installing EPEL and Remi repository.

The Remi repository stores the latest builds of php on Linux. To enable the Remi repository, you first need to install the Epel repository.

Epel repository installation command:

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

centos install epel

We agree to install the Epel repository.

 

Remi repository installation command:

$ sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm

centos install remi

We agree to install the Remi repository.


 

3. View available PHP builds.

Now that we have successfully installed epel and remi repositories into our system, we can now view which versions of php are available for installation. To view the available versions, use the command:

$ sudo dnf module list php

php modules list

As we can see, in the standard AppStream repository only php 8.1 and 8.2 are available, and in the Remi repository php 8.4 is already available.


 

4. Installing PHP.

Now it's time to install php itself, we will install version php 8.4. To install php, let's first reset all the settings for the php module, for this we use the command:

$ sudo dnf module reset php

 

After the reset, enable the PHP module version 8.4, for this use the command:

$ sudo dnf module install php:remi-8.4

php install module-8.4

We agree to install the PHP module version 8.4

 

Now it's time to install PHP itself, for this we use the command:

$ sudo dnf install php

install php

We agree to install php.


 

5. Checking PHP version.

After installing php, we only need to check whether we really installed php version 8.4 or not, for this we use a simple command:

$ php -v

check version php

As a result, we see that I have PHP version 8.4 installed, which means I did everything correctly.


 

In the end, we looked at a fairly simple process of installing the php 8.4 programming language on CentOS 9, including the process of installing the Epel and Remi repositories.

 

SIMILAR ARTICLES

No related articles