How to Install PHP 8.3, 8.2, 8.1 on Fedora 40 or 39

PHP is a versatile server-side scripting language that powers many websites and applications worldwide. With the ongoing development of PHP, the recent stable releases of versions 8.3, 8.2, and 8.1 introduce a range of features, enhancements, and security improvements. Each version builds on the last, offering developers new tools to create more robust, efficient, and secure web applications. These updates include better type safety, performance optimizations, and enhanced error handling, making them essential for modern PHP development.

On Fedora 40 or 39, you can easily install the latest stable builds of PHP using Remi’s RPM repository. This trusted repository consistently delivers up-to-date PHP packages, ensuring that your development environment remains current and capable of leveraging the newest features in PHP. This guide will walk you through the steps to configure Remi’s RPM repository and install PHP 8.3, 8.2, or 8.1 on your Fedora system.

Import Remi RPM Repository

Update Fedora Linux Before PHP Installation

Update the system before you install PHP and its extensions. Run the following commands in a terminal to achieve this:

sudo dnf upgrade --refresh

Import PHP Remi RPM Repository

Follow this simple process to install the Remi PHP repository on Fedora systems. Unlike RHEL and its clones, Fedora doesn’t need EPEL. To import the Remi PHP repository that matches your Fedora version, execute the command below:

Note: The latest versions are below, and we will update this article when new Fedora releases come back on this article.

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

Enable PHP Remi Repository

Before installing different versions of PHP, it’s a good idea to check which versions are available in the REMI repository. Listing the available PHP modules first can give you a better idea of what’s on offer and help you decide which version to install. It’s also worth noting that you can change your selection later if needed, so don’t feel you must make a final decision immediately.

Run the following command to list the PHP modules available:

sudo dnf module list php

The system might prompt you to import the GPG key for Remi’s repository to proceed with the installation.

If it does, enter (Y) to continue.

Now that you’ve looked at the available PHP versions, it’s time to run the command to enable the version you want to install:

sudo dnf module enable php:remi-8.3 -y
sudo dnf module enable php:remi-8.2 -y
sudo dnf module enable php:remi-8.1 -y

Select the PHP Version you wish to Install via DNF Command

You are ready to install PHP with the Remi PHP repository now enabled. The following options guide you in choosing between Apache and Nginx. However, if you know, you can further customize the installation by installing specific extensions for your CMS or software development needs.

Apache HTTP installations with PHP, use the following command:

sudo dnf install php php-cli -y

For Nginx installations with PHP, use the following command:

sudo dnf install php-fpm php-cli -y

To confirm the successful installation of PHP, run the following command after finishing the installation process.

php -v

You can run the command below to obtain the most commonly used extensions for your chosen version of PHP. However, make sure to remove any extensions that you know you won’t need for your specific use case:

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 php-dom php-redis php-memcached php-memcache

Another method to install the commands above is using the PHP-{extension} format.

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

You can execute the command below anytime to view the currently loaded modules:

php -m

It’s a good practice to keep an eye on the installed modules and remove any unnecessary ones, as too many installed modules can negatively impact system performance.

To install the development branch of PHP, use the command below:

sudo dnf install php-devel

To install additional development tools like debugging, use the command below:

sudo dnf install php-xdebug php-pcov

Remember that installing this version will add multiple dependencies. We don’t recommend it unless you need it for your PHP development or have a particular requirement.

Conclusion

By installing PHP on Fedora through Remi’s RPM repository, you’ve ensured that your system is equipped with the latest stable versions of PHP, keeping your environment secure and feature-rich. This approach is ideal for developers who require the most current PHP capabilities to build and maintain modern applications. Regularly updating from Remi’s repository will help you stay ahead with the latest improvements and security patches, ensuring your Fedora system remains optimized for PHP development.

Leave a Comment