How to Install PHP 8.1 on Fedora 35

PHP 8.1 is a significant update of the PHP language that will be “officially” released on November 25, 2021. This is a standard upgrade going forward from the existing PHP 8.0 release with the new PHP 8.1 is bringing enums, fibers, never return type, final class constants, intersection types, read-only properties amongst the long list of new features and changes.

In the following tutorial, you will learn how to import the REMI Module and install PHP 8.1 on your Fedora 35 system.


  • Recommended OS: Fedora Linux 35
  • User account: A user account with sudo or root access.

Update Operating System

Update your Fedora operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@fedora ~]$ sudo whoami

To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Fedora.

To use the root account, use the following command with the root password to log in.


Install Dependency Required

Before you proceed with the installation, run the following command to install or check that the package dnf-plugins-core is installed on your Fedora desktop.

sudo dnf install dnf-plugins-core -y

By default, this should be installed.


Install PHP 8.1 Remi Repository

Currently, PHP 8.1 is not featured in Fedora 35, however this can be easily fixed with installing and enabling the Remi Repository which is a free and stable YUM/DNF repository mainly for the PHP stack. It contains packages for the latest versions of PHP.

To install import and install the remi repo, use the following (dnf) terminal command:

sudo dnf install

Next, verify the installation.

dnf repolist | grep remi

Example output:

remi-modular                  Remi's Modular repository - Fedora 35 - x86_64

Enable PHP 8.1 (Remi) Repository

PHP 8.0 is the default PHP choice for standard Fedora 35 installations.

A quick tip is to use the (list php) command to see the options available and the default.

The following dnf module list command can do this:

sudo dnf module list php

Note, you will be prompted to import the GPG key for Remi’s repository. Type (Y) to proceed if your encounter it.

To reset the PHP list is easy with the following command:

sudo dnf module list reset php -y

Next, enable PHP 8.1 with the following command:

sudo dnf module enable php:remi-8.1

Example output:

How to Install PHP 8.1 on Fedora 35

Install PHP 8.1 on Fedora

Now that you have added the Remi PHP repository and enabled PHP 8.1 to be the default version on your Fedora system, you can install PHP 8.1 with the following command:

sudo dnf install php

Example output:

How to Install PHP 8.1 on Fedora 35

Type “Y,” then press the “ENTER KEY” to proceed with the installation.

Note, you will be prompted for more GPG key imports.


How to Install PHP 8.1 on Fedora 35

Type “Y,” then press the “ENTER KEY” to proceed with the installation.

Optionally, if you would like to install the most commonly used extensions for PHP 8.1, use the following command:

sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml

Note, remove the options you do not want this is optional.

Example output:

How to Install PHP 8.1 on Fedora 35

Type “Y,” then press the “ENTER KEY” to proceed with the installation.

Now that you have installed PHP 8.1 and the extensions, check the version with the following command:

php -v

Example output:

How to Install PHP 8.1 on Fedora 35

PHP-FPM Installations of PHP 8.1

Unlike PHP-FPM installations on Debian/Ubuntu that use the (www-data) user, this isn’t the case with RHEL family installations. By default on AlmaLinux, the PHP-FPM service is designed to be run (Apache) user, which is incorrect since we are using Nginx, and this needed to be corrected.

Firstly, open following (www.conf) configuration file:

sudo nano /etc/php-fpm.d/www.conf

Next, replace the (Apache) user and group with the (Nginx) user and group:

How to Install PHP 8.1 on Fedora 35

To save, press (CTRL+O) then exit (CTRL+X).

Now you will too reload or restart your PHP-FPM service:

sudo systemctl restart php-fpm

Nginx Configurement

The Nginx server block needs the following example below for Nginx to process the PHP files.

Below, example for all server blocks that process PHP files that need the location ~ .php$ added.

server {
 # … some other code
 # Pass the php scripts to FastCGI server specified in upstream declaration.
	location ~ \.php(/|$) {
		include fastcgi.conf;
                fastcgi_pass unix:/run/php-fpm/www.sock;
		fastcgi_split_path_info ^(.+\.php)(/.*)$;
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
		fastcgi_param DOCUMENT_ROOT $realpath_root;
		try_files $uri $uri/ /app.php$is_args$args;
		fastcgi_intercept_errors on;	

Test Nginx to make sure you have no errors with the adjustments made with the code above; enter the following.

sudo nginx -t

Example output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart Nginx service for installation to be complete.

sudo systemctl restart nginx

Comments and Conclusion

In the tutorial, you have learned how to install PHP 8.1 and configure how to use it with Apache and Nginx. PHP 8.1 is exciting. However, at the current moment, it is still coming out of beta and not considered stable, such as 8.0 or the old stable 7.4, so beware you may find that many of your favorite software like WordPress or Plugins/Themes for CMS software may conflict until developers can update.

Do some research, prepare, and have PHP 7.4 or 8.0 installed and ready to replace if anything goes wrong when making the switch. The stable versions such as 8.0 are still actively developed, and packages are pushed simultaneously along with the 8.1 packages.

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x