How to install PHP 8.1 on CentOS 9 Stream

Estimated reading: 3 minutes 701 views

Introduce

What is PHP?

PHP 8.1 is the current latest stable release of the PHP scripting language Hypertext Preprocessor. It has been available in almost all web hosting provider to support their clients in managing or hosting their websites or blogs. PHP-FPM (FastCGI Process Manager) is a PHP FastCGI implementation which mostly used for heavy-loaded production environments.

PHP-FPM is commonly used with a Nginx web server in some production server environments, where the system usually works under high load. But, in another way, it is also often used with Nginx Reverse Proxy in the front of the Apache web server as its backend with MultiPHP-FPM Support.

What’s New in PHP 8.1?

  • Enums have been integrated
  • Read-only properties (Class properties can be marked as read-only and thus can only be written once.
  • Never keyword (A new return type hint named Never was added in PHP 8.1)
  • DNS over HTTPS (DoH) support.
  • Support AVIF Image format.
  • Added support for Fibers (Low-level mechanism for parallel management).
  • The PHP Curl extension now supports HTTP(S) requests with File upload.
  • Support for new fdatasync() and fsync() functions. 
  • PHP 8.1 adds array_is_list as a built-in function.
  • Speed ​​efficiency improved  from 5% to 8% compared to the old version
  • Unpack the array using string keys.

Install PHP 8.1 on CentOS 9

Since the default YUM repository in CentOS 9 does not have PHP 8.1 packages available, we will use the REMI repository to install 8.1 on CentOS 9

Step 1: SSH into the server

To install PHP 8.1 on CentOS 9, the first thing we need to do is SSH or access your VPS or server with root privileges.

After successfully SSH, we continue with step 2.

Step 2: Install PHP 8.1 on CentOS 9

To get started, you need to add the Remi repository first so that from there you will be able to install PHP 8.1 on CentOS 9.

To install and activate the Remi repository on CentOS 9, you need to run the following commands:

yum install epel-release && yum install remi-release
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

Below is the output after running the above commands.

Instructions for installing PHP 8.1 on CentOS7
  • Next, you can make a list of available PHP versions using DNF module commands. Simply run the following command to list all available PHP versions in your CentOS 9 Stream.
dnf module list php
dnf module enable php:remi-8.1 -y

In the next step simply run the following command to install PHP 8.1 with FastCGI Process Manager (PHP-FPM) sometimes called a PHP81-FPM.

dnf install php-fpm php php-bcmath php-cli php-common php-gd php-imap php-mbstring php-mcrypt php-mysql php-mysqlnd php-pdo php-soap php-tidy php-xml php-xmlrpc php-opcache php-redis php-pecl-mcrypt php-brotli

Below is the output after running the above commands

Instructions for installing PHP 8.1 on CentOS7

You can utilize the following available commands to manage your PHP-FPM in your CentOS 9 machine.

systemctl status php-fpm

Enable PHP-FPM to start automatically from boot

systemctl enable php-fpm

To Start PHP-FPM

$ systemctl start php-fpm

To Stop PHP-FPM

$ systemctl stop php-fpm

To Restart PHP-FPM

$ systemctl restart php-fpm
To Check the PHP-FPM Service State
$ systemctl status php-fpm

Step 3: Check the PHP version after installation

After you have installed it, you can check the PHP version again with the following command:

php -v

Below is the output after running the above command

Instructions for installing PHP 8.1 on CentOS7

As shown, I have successfully installed PHP 8.1 on CentOS 9.

Summary

So in this article, I showed you how to install PHP 8.1 on a CentOS 9 stream in a very simple and fast way. PHP 8.1 will certainly bring many new utilities, thus helping applications or websites to operate with maximum efficiency and stability. Hope the article will help you and wish you success.

Leave a Comment

Share this Doc

How to install PHP 8.1 on CentOS 9 Stream

Or copy link

CONTENTS