How To Install PHP 8 on Fedora 37

Install PHP 8 on Fedora 37

In this tutorial, we will show you how to install PHP 8 on Fedora 37. For those of you who didn’t know, PHP is an open-source, general-purpose scripting language mainly used in web development but has also been used as a general-purpose programming language. The new PHP 8.1 brings enums, fibers, never return type, final class constants, intersection types, and read-only properties among new features and changes.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of PHP 8 on a Fedora 37.

Prerequisites

  • A server running one of the following operating systems: Fedora 37.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo useror access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install PHP 8 on Fedora 37

Step 1. Before proceeding, update your Fedora operating system to make sure all existing packages are up to date. Use this command to update the server packages:

sudo dnf upgrade
sudo dnf update

Step 2. Add PHP Repository.

To install PHP on Fedora, you need to set up the REMI repository. Now import the Remi PHP repository using the following command below:

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

Now, verify the installation:

dnf repolist | grep remi

Output:

[root@idroot.us ~]$ dnf repolist | grep remi
remi Remi's RPM repository - Fedora 37 - x86_64
remi-modular Remi's Modular repository - Fedora 37 - x86_64

Step 3. Installing PHP 8 on Fedora 37.

By default, the PHP package come in the default repository of Fedora 37. Now run the following command below to install the PHP 8.1 packages to your Fedora system:

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

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

After installing PHP, use the below command to check its version:

php -v

Output:

PHP 8.1.13 (cli) (built: Nov 28 2022 11:36:13) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies

Congratulations! You have successfully installed PHP. Thanks for using this tutorial for installing PHP 8 on your Fedora 37 system. For additional help or useful information, we recommend you check the official PHP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!