How to install or upgrade to PHP 8.3 on Fedora, RHEL, CentOS, and more

Published On21 Nov 2023

How to install or upgrade to PHP 8.3 on Debian and Ubuntu

PHP 8.3 is 2023's major update to PHP, bringing a handful of new features such as typed class constants, granular Exceptions in DateTime extension, the new json_validate function, functionality changes and improvements, and deprecations. Just like PHP did in previous major versions, PHP 8.3 brings several bug fixes and performance improvements as well.

This article explains how to install PHP 8.3 on modern Fedora, Red Hat Enterprise Linux, and other systems that are binary compatible with RHEL, such as CentOS Stream, Alma Linux, and Rocky Linux. It uses the repository maintained by Remi Collet, who has been maintaining PHP packages on these systems for over a decade.

A similar guide is also available for Installing/Upgrading PHP 8.3 on Debian and Ubuntu.

This installs PHP 8.3 as a Software Collection, and multiple PHP versions can co-exist on the same system.



Quick-Start

In the terminal as a sudo-capable user, run the following commands for Fedora or RHEL/Alma/Rocky/CentOS Stream. For detailed steps, go to the Detailed Installation/Upgrade guide.

Install PHP 8.3 on Fedora 37, 38, and 39

# Save existing php package list to packages.txt file
sudo dnf list installed | grep php | tee packages.txt

# Add Remi's repo
sudo dnf install https://rpms.remirepo.net/fedora/remi-release-$(cut -d ' ' -f 3 /etc/fedora-release).rpm
sudo dnf config-manager --set-enabled remi

# Install new PHP 8.3 packages
sudo dnf install php83 php83-php-fpm

# Remove old packages
sudo dnf remove php82*

# Create symlinks from `php` to actual PHP binary
sudo dnf install php83-syspaths -y

Install PHP 8.3 on RHEL/Alma/Rocky/CentOS Stream/etc

Requires RHEL 8.8 or 9.2, or Alma/Rocky/CentOS Stream/EL versions based on Enterprise Linux 8 or 9.

# Save existing php package list to packages.txt file
sudo dnf list installed | grep php | tee packages.txt

# Add Remi's repo
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(cut -d ' ' -f 4 /etc/redhat-release | cut -d '.' -f 1).noarch.rpm -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-$(cut -d ' ' -f 4 /etc/redhat-release | cut -d '.' -f 1).rpm -y

# Install new PHP 8.3 packages
sudo dnf install php83 php83-php-fpm

# Remove old packages
sudo dnf remove php82*

# Create symlinks from `php` to actual PHP binary
sudo dnf install php83-syspaths -y

Detailed Installation/Upgrade guide

1. Prerequisites

The steps listed in this article should work with Fedora 37, 38, and 39, RHEL 8.8 and 9.2, and Enterprise Linux derivatives such as Alma, Rocky, CentOS Stream, etc based on EL 8 and 9.

Heads up: Potentially destructive actions ahead The following actions are executed as sudo, and require that level of permissions to continue. The usual warnings when making any system-wide changes apply here as well. Make sure to backup the system and check the backups before continuing. When upgrading, do not forget to migrate configuration to the new PHP version.

2. List and keep note of existing PHP packages

When upgrading an existing PHP version, the following command lists all packages installed with the word php in the package name, and saves it to a packages.txt file as well as printing it in the terminal.

This will be helpful to install the corresponding PHP 8.3 packages in the next steps.

This step is not necessary when installing PHP on a new system.

sudo dnf list installed | grep php | tee packages.txt

3. Add Remi's repository

The first Fedora version to contain PHP 8.3 by default would be Fedora 40. What this means is that for Fedora 37 through 39, PHP must be compiled from source, or should come from an external repo. This step will not be necessary on Fedora 40 and later.

On RHEL and derivatives, based on Enterprise Linux 8 or 9, there are no PHP 8.3 packages in their default repositories either.

Remi Collect maintains several repositories for Fedora, RHEL, and Enterprise Linux (Alma, Rocky, CentOS, etc are compatible with EL), which includes PHP 8.3 and several PECL extensions. This article explains how to add the appropriate repository and use packages available on Remi's repo.

The following commands add the repository to the list of software repositories for dnf. It does not overwrite any other PHP packages on different PHP versions. It is possible for multiple PHP versions to co-exist. See Running PHP 8.3 Alongside Other Versions for more information.

Fedora 37, 38, and 39

sudo dnf install https://rpms.remirepo.net/fedora/remi-release-$(cut -d ' ' -f 3 /etc/fedora-release).rpm
sudo dnf config-manager --set-enabled remi

RHEL/Alma/Rocky/CentOS/etc

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(cut -d ' ' -f 4 /etc/redhat-release | cut -d '.' -f 1).noarch.rpm -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-$(cut -d ' ' -f 4 /etc/redhat-release | cut -d '.' -f 1).rpm -y

4. Install New PHP 8.3 Packages

With Remi's repo added and enabled, PHP packages can be installed using dnf. The main php83 package installs common PHP extensions as well as PHP CLI. Additional extensions (including PECL extensions) follow the php83-php-XYZ pattern where XYZ is the name of the extension.

sudo dnf install php83 php83-php-fpm
  • The php83 package installs several common PHP packages for popular PHP extensions. This installs the PHP CLI package as a dependency (php83-php-cli).

  • php83-php-fpm installs PHP's FPM SAPI for web server integration. See Web Server Integration for more information.

5. Additional PHP Extensions

The main php83 package installs a few PHP extensions such as FPM, PDO, Opcache, XML, and Sodium. The Remi repo contains several PHP core extensions and PECL extensions that can easily be installed with dnf.

PHP Core extensions use the naming pattern php83-php-XYZ, while PECL extensions are named php83-php-pecl-XYZ. When there are no name collisions, the PECL extensions are also available at php83-php prefix.

The following are some of the PHP core and PECL extensions and their package names to be used with dnf install to install.

Extension name Package name
Intl php83-php-intl
BCMath php83-php-bcmath
Xdebug php83-php-pecl-xdebug
Redis php83-php-pecl-redis
PCov php83-php-pecl-pcov
Image Magick php83-php-pecl-imagick
APCu php83-php-pecl-apcu
sudo dnf install php83-php-pecl-xdebug

The following runs a simple search on dnf:

sudo dnf search php83-php | grep apcu # Look for "APCu" extension

Some PECL extensions may not be available on PHP 8.3 if the upstream extension does not compile on PHP 8.3 due to compatibility issues.

When upgrading, refer to the pacakges.txt file created in step #2 to reinstall the PHP 8.3 packages of the old PHP version.

6. Web Server Integration

PHP being a web programming language, it is very common to integrate PHP with a web server. Integrating with PHP-FPM over Fast CGI protocol is the most common approach, while it is also possible to integrate PHP with other SAPIs and frameworks such as Swoole.

Enable and start PHP 8.3 FPM Service

The php8.3-php-fpm package creates the necessary systemd unit files to run PHP 8.3 FPM as a system service, but it does not enable it by default.

To enable it to automatically run on server start, and immediately start the service, run the following:

sudo systemctl enable php83-php-fpm
sudo systemctl start php83-php-fpm

Apache web server When installing the php83-php-fpm package, if Apache web server (apache2) is present, there will be a new /etc/httpd/conf.d/php83-php.conf file which conveniently enables PHP support automatically.

When upgrading from an existing PHP version, make sure to remove the old phpXX-php.conf files from /etc/httpd/conf.d directory.

Nginx, Caddy, Litespeed, and other servers over Fast CGI

The default UNIX socket address for PHP 8.3-FPM from Remi repo is /var/opt/remi/php83/run/php-fpm/www.sock

For web servers such as Nginx, Caddy, Litespeed, etc. that integrate with PHP over Fast CGI, change/configure the UNIX socket path to this UNIX socket address. For example on Nginx, this involves changing the fastcgi_pass directive:

- fastcgi_pass unix:/var/opt/remi/php82/run/php-fpm/www.sock;
+ fastcgi_pass unix:/var/opt/remi/php83/run/php-fpm/www.sock;

See How to use Caddy Server with PHP for a detailed article on using Caddy server with PHP.

7. Test PHP 8.3 Installation

After installing all the packages, comes the moment of truth to see if the new installation was successful.

Running php83 -v in the terminal should show something like this:

php -v output
Calling `php83 -v` displays the PHP version number and build date.

Invoke PHP 8.3 CLI from php See Running PHP 8.3 Alongside Other Versions to invoke PHP 8.3 CLI from php command. Because this guide encourages the possibility of installing multiple PHP versions alongside each other, PHP 8.3 CLI is invoked as php83 by default.

The list of modules can be listed with php -m. This list will include several bundled PHP extensions. See Migrate Configuration on migrating the PHP INI directives and enabled extensions to the new PHP versions.

8. Migrate Configuration

This step only applies when updating to PHP 8.3 from an older PHP version

Configuration files for the new PHP 8.3 installation are in the /etc/opt/remi/php83 directory. Existing PHP installations should also be in the /etc/opt/remi/ or /etc/php directories.

Do not copy existing PHP INI files to /etc/opt/remi/php83. While it may work when upgrading from PHP 8.2 or a recent version, manually copying the INI directives is recommended.

See What's new and changed in PHP 8.3 to see the deprecated INI directives and the new INI directive added in PHP 8.3.

When using PHP-FPM, make sure to replicate the correct number of FPM processes and process models (e.g. in /etc/opt/remi/php83/php-fpm.d/www.conf file).

Load files for PHP extensions are located at /etc/opt/remi/php83/php.d. Removing a file will disable the corresponding PHP extension.

After making changes, restart PHP 8.3-FPM:

sudo systemctl restart php8.3-fpm

9. Remove old PHP Versions

This step only applies when updating to PHP 8.3 from an older PHP version

To remove old PHP versions, run dnf remove with the PHP version prefix. For example, the following removes the packages and configuration for PHP 8.2:

sudo dnf remove php82*

Running PHP 8.3 Alongside Other Versions

This article intentionally avoids overwriting existing PHP packages by installing PHP 8.3 packages with the php83 prefix. This way, it is possible to install and run multiple PHP versions simultaneously.

On Linux systems, PHP-FPM runs as a UNIX socket with each PHP version using a different socket address. It is also possible to have multiple PHP FPM processes, and the web server can selectively use different PHP versions for different contexts (e.g. PHP 8.3 for example.com, while using PHP 8.2 for example.net).

PHP CLI binaries are available globally with php83, which also encourages running multiple PHP CLI versions simultaneously.

Global php executable

Some scripts may require PHP CLI to be present as php. Installing the php83-syspaths package from dnf automatically creates a symlink from /usr/bin/php to the actual PHP 8.3 CLI executable, fulfilling this use case.

Installing the php83-syspaths package when another phpXY-syspaths package exists will result in a DNF installation error due to the conflict trying to claim the /usr/bin/php symlink. Remove other syspaths packages before attempting to install php83-syspaths.

dnf remove php82-syspaths
dnf install php83-syspaths

Further Resources

Recent Articles on PHP.Watch

All ArticlesFeed 
How to fix `mysql_native_password` not loaded errors on MySQL 8.4

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to fix the SQLSTATE[HY000] [1524] Plugin 'mysql_native_password' is not loaded errors caused in MySQL 8.4 no longer enabling the mysql_native_password plugin by default.
How to fix PHP Curl HTTPS Certificate Authority issues on Windows

How to fix PHP Curl HTTPS Certificate Authority issues on Windows

On Windows, HTTPS requests made with the Curl extension can fail because Curl has no root certificate list to validate the server certificates. This article discusses the secure and effective solutions, and highlights bad advice that can leave PHP applications insecure.
AEGIS Encryption with PHP Sodium Extension

AEGIS Encryption with PHP Sodium Extension

The Sodium extension in PHP 8.4 now supports AEGIS-128L and AEGIS256 Authenticated Encryption ciphers. They are significantly faster than AES-GCM and CHACHA20-POLY1305. This article benchmarks them and explains how to securely encrypt and decrypt data using AEGIS-128L and AEGIS256 on PHP.
Subscribe to PHP.Watch newsletter for monthly updates

You will receive an email on last Wednesday of every month and on major PHP releases with new articles related to PHP, upcoming changes, new features and what's changing in the language. No marketing emails, no selling of your contacts, no click-tracking, and one-click instant unsubscribe from any email you receive.

Support PHP.Watch — If you find the articles, version information, Codex, and other PHP.Watch contributions useful, consider supporting through GitHub Sponsors. Your sponsorship helps dedicate more time to creating valuable content and improving the PHP community. Together, we can keep the momentum going — thank you for your support!

Thanks to the highest tier sponsor: @TomasVotruba for your generous support to keep PHP.Watch moving 💜