Guides 11792 Published by

The guide walks you through adding the EPEL repository and the REMI release RPM on CentOS 9 Stream, then resetting the built‑in PHP module stream and enabling php:remi-8.0 so DNF can see the newer interpreter instead of the default 7.x packages. After that you install the core PHP 8.0 packages (cli, common extensions, and either mod_php for Apache or php-fpm for Nginx) with a single dnf install -y php … command. A quick php -v confirms the version, and optional sed edits to /etc/php.ini enable full error reporting for development. If anything goes wrong you can revert by resetting the module stream back to the older 7.4 series.



How to Install PHP 8.0 on CentOS 9 Stream

You’ll get a working PHP 8.0 stack without pulling in a whole LAMP distro you’ll never use. The steps walk you through enabling the right third‑party repos, installing the packages, and confirming everything runs as expected.

Enable EPEL and REMI – the only repositories that actually carry PHP 8.0 for Stream

CentOS 9 Stream ships with PHP 7.x in its base repo, so we have to reach outside. I’ve run into broken apps countless times after a “yum install php” gave me an outdated interpreter; the fix is always the same: add EPEL first, then REMI.

sudo dnf install -y epel-release

epel-release pulls in a large collection of extra packages and makes DNF aware of the new repo file.

sudo dnf install -y https://rpms.remirepo.org/enterprise/remi-release-9.rpm

The REMI package drops a repo file under /etc/yum.repos.d that points to the “remi” stream where PHP 8.0 lives. If you skip this, DNF will never see the newer version.

Reset the module stream to PHP 8.0

CentOS 9 Stream uses modular streams for language runtimes. By default it’s locked to PHP 7.4; we have to tell it to switch.

sudo dnf module reset php -y
sudo dnf module enable php:remi-8.0 -y

Reset clears the old selection, and enable points the system at REMI’s 8.0 stream. This step matters because without resetting, DNF will refuse to install a higher version and you’ll get a cryptic “module conflict” error.

Install the core PHP packages

Now pull in what most web apps need: the interpreter itself, common extensions, and the Apache module (or php-fpm if you run Nginx).

sudo dnf install -y php php-cli php-common php-mbstring php-xml php-json php-gd php-pdo

If you’re on Apache:

sudo dnf install -y mod_php

For Nginx with PHP‑FPM:

sudo dnf install -y php-fpm

Choosing the wrong SAPI is a classic mistake; I’ve seen sites break because someone installed mod_php but was actually using Nginx, which can’t talk to Apache’s module.

Verify the installation

A quick version check tells you if everything landed where it should.

php -v

You should see something like “PHP 8.0.x (cli)”. If the output still shows 7.x, double‑check that the REMI repo is enabled (dnf repolist | grep remi) and that you didn’t have a leftover PHP package from the base repo.

Optional: tweak php.ini for development

The default php.ini shipped by REMI is pretty strict. For local testing I usually enable error reporting:

sudo sed -i 's/display_errors = Off/display_errors = On/' /etc/php.ini
sudo sed -i 's/error_reporting = .*/error_reporting = E_ALL/' /etc/php.ini

These two lines flip the switch so PHP will shout at you when something’s wrong, which saves a lot of head‑scratching later.

That’s it – you’ve got PHP 8.0 running on CentOS 9 Stream without any unnecessary bloat. If anything goes sideways, roll back to the previous module stream with dnf module reset php && dnf module enable php:remi-7.4.