How to Install PHP 8 on Linux CentOS/RHEL 8/7
Last updated: Jan 16, 2022
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:
- Enable the EPEL repository.
- Enable Remi repository.
- Remove old PHP.
- 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
STEP 2. Enable the Remi repository.
sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
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
STEP 4. Install PHP 8.1
View available PHP modules:
sudo dnf module list php
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
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
After installation, check the version of PHP that is installed.
READY! PHP version 8.1 is installed.
Thank you all, I hope my article was of some help to you.