How to Install PHP 8 on Linux CentOS/RHEL 8/7

  • Last update: Apr 3, 2024
  • Views: 75
  • Author: Admin
How to Install PHP 8 on Linux CentOS/RHEL 8/7

Hello colleagues.

In today's article I will tell you how to install php 8.1 on Linux CentOS/RHEL 8/7.

PHP is an open source server-side scripting language that was officially released on November 25, 2021.

As of today PHP 8 is not featured in the AppStream and CentOS Stream repositories as it is still relatively new and has not yet been filtered in the RHEL repositories.

However, you can install PHP from the Remi repository.

The content of the article:

  1. Enable the EPEL repository.
  2. Enable Remi repository.
  3. Remove old PHP.
  4. Installing PHP 8.1

 

STEP 1. Enable the EPEL repository.

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

how to install php 8.1 on linux


STEP 2. Enable the Remi repository.

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

how to install php 8.1 on linux


STEP 3. Remove old PHP if you have it installed.

If you want to remove the old PHP with all extensions, then run the commands:

Remove PHP itself:

sudo dnf remove php php-fpm

Remove other PHP extensions:

sudo dnf remove php*

Reset the list of PHP modules:

sudo dnf module list reset php

how to install php 8.1 on linux


STEP 4. Install PHP 8.1

View available PHP modules:

sudo dnf module list php

how to install php 8.1 on linux

The (d) tag is next to PHP 7.2, you need to reset it to install PHP 8.1.

sudo dnf module enable php:remi-8.1

how to install php 8.1 on linux

Now that you have added the Remi PHP repository and enabled PHP 8.1 as the default version, you can install PHP 8.1.

sudo dnf install php php-cli php-common

how to install php 8.1 on linux

After installation, check the version of PHP that is installed.

php -v

how to install php 8.1 on linux

READY! PHP version 8.1 is installed.

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

SIMILAR ARTICLES

How to uninstall PHP on Centos 8
How to uninstall Apache on Centos 8
Installing Apache Web Server on CentOS 8
How to Install Nginx on CentOS/Redhat