Installing the distro-packaged PHP runtime on CentOS Stream, Fedora, or Red Hat Enterprise Linux (RHEL) adds a supported interpreter for cron jobs, deployment helpers, maintenance scripts, and later application work without committing the host to a web-server stack on the first install.

Current Red Hat family packages split PHP into a small php metapackage, the actual CLI binary in php-cli, common runtime files in php-common, and optional pieces such as php-mysqlnd, php-xml, or php-fpm in separate subpackages. That layout keeps the first install flexible, but it also means the generic php package alone is broader than a clean CLI-only runtime.

Current package behavior differs mainly on RHEL 9. The default AppStream path still resolves php to PHP 8.0 there, while Fedora 42 currently ships PHP 8.4 and current CentOS Stream 10 and RHEL 10.1 package sets resolve PHP 8.3 as non-modular packages. DNF installs weak dependencies by default, so a plain dnf install php can also pull php-fpm, httpd, and extra modules unless the transaction is narrowed deliberately.

Steps to install PHP on CentOS, Fedora, or Red Hat:

  1. Inspect the PHP package currently exposed by the enabled repositories.
    $ sudo dnf info php
    Available Packages
    Name         : php
    Version      : 8.3.29
    Release      : 1.el10
    Architecture : aarch64
    Repository   : appstream
    Summary      : PHP scripting language for creating dynamic web sites

    Current official package checks show php-8.4.19-1.fc42 on Fedora 42, php-8.3.29-1.el10 on CentOS Stream 10, php-8.3.29-1.el10_1 on RHEL 10.1, and php-8.0.30-5.el9_7 on the default RHEL 9.7 AppStream path.

  2. List the available PHP module streams on RHEL 9 when the host needs a newer branch than the default PHP 8.0 path.
    $ sudo dnf module list php
    Red Hat Universal Base Image 9 (RPMs) - AppStream
    Name Stream Profiles               Summary
    php  8.1    common, devel, minimal PHP scripting language
    php  8.2    common, devel, minimal PHP scripting language
    php  8.3    common, devel, minimal PHP scripting language

    Skip this step on Fedora, CentOS Stream 10, or RHEL 10, where the packaged PHP path is already non-modular.

    Use the minimal profile when RHEL 9 needs a newer CLI runtime without the web stack, for example sudo dnf module install --assumeyes php:8.3/minimal.

  3. Install the packaged CLI runtime without the default weak web-stack dependencies.
    $ sudo dnf install --assumeyes --setopt=install_weak_deps=False php php-cli
    ##### snipped #####
    Installing:
     php        8.3.29-1.el10
     php-cli    8.3.29-1.el10
    Installing dependencies:
     php-common 8.3.29-1.el10

    Current transaction checks on CentOS Stream 10 and RHEL 10.1 resolve only php, php-cli, and php-common with this command. A plain sudo dnf install --assumeyes php is broader because current package definitions recommend php-cli, php-fpm, httpd, and extra modules, and DNF installs weak dependencies by default.

  4. Verify that the php interpreter is installed and reporting the packaged CLI build.
    $ php -v
    PHP 8.3.29 (cli) (built: Dec 16 2025 14:32:42) (NTS gcc aarch64)
    Copyright (c) The PHP Group

    The first line is the decisive answer: the dotted PHP release and the cli SAPI. The exact version depends on the distro release or selected RHEL 9 module stream.

  5. Install only the additional extension packages the application still needs after the base runtime is working.
    $ sudo dnf install --assumeyes php-mysqlnd

    The narrowed CLI install above leaves database drivers as an explicit follow-up choice. That keeps the first install focused on the interpreter instead of assuming every host also needs MySQL or MariaDB client support.

  6. Confirm that the requested database extension is loaded by the interpreter.
    $ php -m | grep -E '^(mysqli|mysqlnd|pdo_mysql)$'
    mysqli
    mysqlnd
    pdo_mysql

    The php-mysqlnd package enables the common MySQL client interfaces for PHP, so seeing mysqli, mysqlnd, and pdo_mysql confirms that the driver stack is active in the same CLI runtime the shell resolves.