php 8.1 install fedora

Looking for a simple way to install PHP 8.1 on Fedora? You can easily get the PHP 8.1 packages from the Remi repository. PHP is a versatile scripting language widely used to build dynamic websites and robust web applications. It was first created by Rasmus Lerdorf back in 1994.

In this tutorial, we’ll walk you through the steps to install and run PHP 8.1 on a Fedora Linux system. Whether you’re using a cloud server, an on-premises Fedora installation, or your Fedora workstation, this guide will help you get set up.

New Features in PHP 8.1

Below are some new features in PHP 8.1 release. More details about each feature is available in the official PHP website.

  • Readonly properties – Class properties can be marked as readonly hence can only be written once
  • Support for DNS-over-HTTPS (DoH)
  • AVIF Image Format support – The PHP 8.1’s image processing and GD extension adds support for AVIF images.
  • Never Return Type – A new return type hint called never is added in PHP 8.1
  • Added support for Fibers – The low level mechanism to manage parallelism
  • PHP 8.1 adds array_is_list as a built-in function
  • File Uploads with CURLStringFile – In PHP 8.1, PHP Curl extension now supports HTTP(S) requests with file uploads
  • Enums – They are now added in PHP 8.1
  • New fdatasync() and fsync() Functions
  • New Sodium XChaCha20 functions
  • Addition of pure intersection types feature
  • Explicit Octal Numeral Notation
  • Define final Class Constants
  • MurmurHash3 hash algorithm support
  • Intersection Types
  • xxHash hash algorithms support
  • For detailed information read through the official PHP 8.1 notes

Install PHP 8.1 on Fedora

For normal PHP requirements, you can go with the latest version available on the default Fedora RPM repositories. For any version of PHP not in the default repos, you’ll be required to add third party repository such as REMI or build from source.

Step 1: Enable Remi repository

Perform an update on your Fedora system

sudo dnf -y update

Then proceed to enable Remi repository on Fedora.

Fedora 42:

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-42.rpm

Fedora 41:

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-41.rpm

Fedora 40:

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-40.rpm

Step 2: Install PHP 8.1 on Fedora

After addition of REMI repository, disable default AppStream PHP module.

sudo dnf -y module reset php

Enable php:remi-8.1 module

sudo dnf module enable php:remi-8.1
sudo dnf  install php

In older fedora versions you may need:

sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --set-enabled remi
sudo dnf -y module install php:remi-8.1

Check installed version of PHP on your Fedora Linux:

$ php --version
PHP 8.1.32 (cli) (built: Mar 11 2025 22:09:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.32, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.32, Copyright (c), by Zend Technologies

Installing multiple versions of PHP

If you’re interested in having multiple versions of PHP on your Fedora system, then install from php81 collection which is available in the remi-safe repository and can be installed with the command:

sudo dnf install php81

Additional PHP extensions can then be installed using the command:

sudo dnf install php81-php-xxx

To check the version of PHP 8.1 installed using this method, run:

php81 --version

Step 3: Install PHP 8.1 extensions

Install PHP extensions using the name format php-<extension>. 

sudo dnf install php-<extension>

Here is an example to install mostly used extensions of PHP:

sudo dnf install php-{cli,fpm,mysqlnd,zip,devel,gd,mcrypt,mbstring,curl,xml,pear,bcmath,json,opcache}

Step 4: Use PHP-FPM on Nginx / Apache

The default PHP configuration file is /etc/php.ini.

sudo cat /etc/php.ini

For Nginx web server, use PHP-FPM (FastCGI Process Manager) configuration file to set CGI settings:

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

Once your PHP and PHP-FPM settings are modified, nginx and httpd web server services can be restarted.

# Nginx
sudo systemctl enable --now php-fpm
sudo systemctl restart nginx

# Apache
sudo systemctl enable --now php-fpm
sudo systemctl restart httpd

You should now have PHP 8.1 installed on Fedora Linux system. Enjoy PHP Development and have an amazing Code time.

Installation of PHP 8.1 on other systems:

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here