Guides 11792 Published by

This guide walks you through adding the Remi RPM repository to a Fedora system, enabling the PHP stream you need—whether it’s 8.2, 8.1, 8.0 or 7.4—and installing the core runtime along with common extensions such as CLI, FPM, MySQLnd, XML, JSON and GD. It shows how to list available PHP modules, activate a specific one with `dnf module enable`, then pull in all the packages at once so your server is ready for Apache, Nginx or other web stacks. After installation you can verify everything by running `php -v` and, if necessary, switch streams later by disabling the current one and enabling another.



Install PHP 8.2 on Fedora – a quick‑and‑dirty guide that actually works

If you’re on Fedora and your site or local dev stack needs PHP 8.2, 8.1, 8.0, or even the old 7.4, you can get it with a handful of dnf commands. Below is a hands‑on walk‑through that skips the fluff and gets you to “works now” in minutes.

What you’ll learn
  • How to add Remi’s repository, which ships all the PHP streams.
  • The exact module enable command for each major version.
  • A single install line that pulls in the core, CLI, and web server packages you normally need.

I’ve seen people run dnf upgrade on a production box, only to find their PHP‑based site back‑flipping because the new PHP 8.1 shipped with a changed default for short_open_tag. That’s why we’ll enable the exact stream you want instead of blindly upgrading everything.

Prerequisites
  • Fedora 38 (or any recent release) with root or sudo access.
  • Basic familiarity with the terminal.

If you’re on an older Fedora, the steps are identical – just swap “38” for your version number in the Remi repo URL.

Add Remi’s RPM repository
sudo dnf install https://rpms.remirepo.net/fedora/remi-release-38.rpm

Why this matters: The default Fedora repos ship only PHP 7.4 (or 8.0 on the very newest releases). Remi supplies all the streams we need, and its repo is maintained by a community that keeps up with security patches.

Check available PHP modules
sudo dnf module list php

You’ll see rows like:

php: 8.2   (active)  [default]
php: 8.1   (available)
php: 8.0   (available)
php: 7.4   (available)

If a stream you want shows as “available,” we enable it next.

Enable the PHP stream you need

Replace <VERSION> with 8.2, 8.1, 8.0, or 7.4.

sudo dnf module enable php:<VERSION>

Example for PHP 8.2:

sudo dnf module enable php:8.2

Why this matters: Enabling the stream tells DNF to pull packages from that specific PHP line and deactivates any other streams that might clash (like the default 7.4). Forgetting to do this can leave you with a mix‑and‑match mess.

Install PHP and common modules
sudo dnf install php \
    php-cli \
    php-fpm \
    php-mysqlnd \
    php-xml \
    php-json \
    php-gd

Why these packages:

  • php is the core runtime.
  • php-cli lets you run scripts from the command line (useful for cron jobs).
  • php-fpm powers Apache, Nginx, or any reverse proxy that needs PHP.
  • The rest are the most common extensions your apps will ask for.

If you’re running an older PHP 7.4 site that relies on legacy extensions like php-mbstring, just add them to the list above.

Verify the installation
php -v

You should see something like:

PHP 8.2.3 (cli) (built: Apr 18 2024 14:12:30) 
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies

If the version matches what you requested, congratulations! Your server is now running that PHP stream.

Optional: Switch between streams later

If you need to roll back or switch to a different version:

1. Disable the current stream:

   sudo dnf module disable php

2. Enable the new one:

   sudo dnf module enable php:<NEW_VERSION>

3. Reinstall PHP packages as shown earlier.

That’s all there is to it. Pick the version you need, enable the module, and install PHP. If your app needs a newer extension (say pdo_mysql), just add it to the install list and let DNF do its thing.