How to Install PHP 8.2 on Linux CentOS/RHEL 8

  • Last updated: Nov 3, 2023
  • Views: 4260
  • Author: Admin
How to Install PHP 8.2 on Linux CentOS/RHEL 8

Hello colleagues.

In today's article, we'll talk about how you can install the latest version 8.2 PHP interpreter on your Linux Centos or Redhat version 8 server.

The PHP programming language is a general-purpose scripting language that is great for developing websites of any complexity. Today, most websites are programmed in PHP. The PHP language can be quickly learned and is very fast because it runs in its own memory space. PHP also has a Zend engine that parses the code and turns it into op codes, which it then interprets into bytecode. Another advantage is that it is free and open source.

 

PHP has very wide support for various databases such as: Mysql, Mariadb, Postgresql, Oracle, Mongodb and so on. PHP also supports all major communication protocols such as LDAP, IMAP, POP3.

 

What's new in PHP 8.2?

  • Readonly Classes - Readonly
  • Data types, specified as disjunctive normal form (DNF)
  • Independent types null, false and true
  • New module "Random" - Random number generation
  • Constants in traits
  • Many additional classes for various tasks

 

Let's start the installation.

 

The first thing we need to do is run the command to install system updates, this is not necessary, but we can do it better. To check for updates, run the command:

$. sudo dnf update -y

install php 8.2 Centos/Redhat 8

Since I ran this command not long ago, the system tells me that no new updates have been found.


 

The next step is to install the EPEl repository. EPEl carries additional Enterprise Linux packages. Enterprise Linux (EPEL) stands for Fedora Special Interest Group, which creates, maintains and manages a high quality set of add-on packages for Enterprise Linux. In order for us to install the EPEl repository, we must run the command:

$. sudo dnf install epel-release

install php 8.2 Centos/Redhat 8

We confirm the installation of the repository and the system will install it for us.


 

At this point, we need to enable the Remi repository. The Remi repository provides packages that carry the latest version of PHP 8.2. In order for us to connect this repository, we use the command:

$. sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

install php 8.2 Centos/Redhat 8

After entering the command, it will ask us to confirm the installation of the repository. We agree with the y key.


 

At this point, let's see what version of PHP will be installed by default. View command:

$. sudo dnf module list php

install php 8.2 Centos/Redhat 8

As you can see, PHP version 7.2 will be installed by default, because version 7.2 is opposite the special sign [d]. The sign [d] means - default, by default.

 

Let's change the default PHP version from 7.2 to 8.2 using the command:

$. sudo dnf module enable php:remi-8.2

install php 8.2 Centos/Redhat 8

Confirm the change with the y key.

 

Now let's check the list of PHP versions again.

$. sudo dnf module list php

install php 8.2 Centos/Redhat 8

As you can see, now the sign [e] has appeared near remi-8.2. The [e] sign means enable, enabled.


 

Now we have to perform the last step, this is to run the PHP installation with the standard command:

$. sudo dnf install php

install php 8.2 Centos/Redhat 8

Confirm the installation with the y key.


 

After installing PHP, let's check which version we have installed, for this we will use a very simple command:

$. php -v

install php 8.2 Centos/Redhat 8

Success! Instead of the default PHP 7.2, we were able to install the latest PHP 8.2.3


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

Linux - How to Install PHP Composer on CentOS 8

Linux - How to Install PHP Composer on CentOS 8

How to Install Galera Cluster Manager on Centos

How to Install Galera Cluster Manager on Centos

Linux tree display of directories, tree command

Linux tree display of directories, tree command