# RHEL and CentOS

> Section in “Introduction › Getting PHP 7” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/introduction/getting-php-7/rhel-and-centos/>

At the time of writing, Red Hat Enterprise Linux (RHEL) 8 and CentOS 8 were the current versions of these RPM-based Linux distributions. Both ship with PHP 7.2 by default.

The [package repository](https://rpms.remirepo.net/) maintained by Remi Collet is commonly used for installing newer PHP versions on RHEL and CentOS, including PHP 7.3 and PHP 7.4. Here is how you can add this repository to your package manager configuration and upgrade to PHP 7.4:

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

    $ sudo dnf install \
      https://rpms.remirepo.net/enterprise/remi-release-8.rpm

    $ sudo dnf install yum-utils

    $ sudo dnf module reset php

    $ sudo dnf module install php:remi-7.4

    $ sudo dnf update

---

Previous: [Getting PHP 7](https://php7explained.com/introduction/getting-php-7/index.html.md) | Next: [Fedora](https://php7explained.com/introduction/getting-php-7/fedora/index.html.md)
