How To Install PHP 8.1-FPM on AlmaLinux 8.5

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

Today we will teach you step by step on how to install and configure PHP 8.1-FPM on a cloud server running under distro flavours AlmaLinux 8.5. Just like Rocky Linux, AlmaLinux is also designed as well to replace CentOS Linux on the web hosting industry. I will stick to use PHP-FPM, since it capable to handle heavy-loaded or busy websites with daily high-traffic, and we can easily adjust the FPM config according to the available server resource.

FPM stand for FastCGI Process Manager, it’s primary PHP FastCGI implementation or PHP daemon which is designed specially for heavy-loaded web applications. PHP-FPM is more robust, advanced and having more features compared to the traditional PHP-CGI daemon or another PHP Handler like CGI, SUPHP or FCGI.

On cPanel-WHM you may know the available implementation of PHP Handler on the WHM >> Software >> MultiPHP Manager, like cgi, fcgi, lsapi, and suphp. It’s similar to PHP Handler and FastCGI Process Manager (FPM) is basically an implementation to manage FastCGI Server API (SAPI) in PHP environment. FPM can adaptively spawns the FastCGI children and release even more if it required to handle current server load.

There are some robust features which available on FastCGI Process Manager (FPM), including child spawning methods like Dynamic, Ondemand or Static, then PHP-FPM Pools, and advanced process management with graceful stop/start. You can set your FPM to run with the available child spawning methods on each PHP versions, either it Dynamic, Ondemand or Static. By default, PHP-FPM will use “ondemand”, so you can change it to “dynamic” for better server performance. However, you need to adjust the pool rules to achieve more performance improvement.

WHM MultiPHP Manager - 100.0.11
WHM MultiPHP Manager – 100.0.11

PHP-FPM Pools can listen on different port number on each PHP version and it can using different php.ini files. Apart from that, the workers proccess can start with different environment like UID, GID or Chroot. There is also emergency restart mode when the system accidentally destruct the opcode cache. Ok, let follow this guide.

READ:  How To Install NGINX v1.21.6 Mainline Branch on AlmaLinux 8.5

PREREQUISITES:

* VPS, CLoud or Bare Metal
* Superuser Privileges (Root Access)
* Server IPv4 Address & Its Password
* Running Under AlmaLinux 8.5 OS
* Gnome Terminal for Linux Desktop
* PuTTy SSH Client for Windows or MacOS

1.) Install EPEL (Extra Packages for Enterprise Linux) and REMI Repositories.

Since you will install extra packages on you node, so we need to add firts the software repository into you system like EPEL and REMI repositories. Kindly run the following command to add both software repository on your node using either dnf or yum commands.

To Install REMI Repository

$ dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Verify the newly installed REMI repository using below command.

$ rpm -qa | grep remi
remi-release-8.5-3.el8.remi.noarch
Install EPEL and REMI Repositories
Install EPEL and REMI Repositories

To Install EPEL Repository

$ dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Then you can check the EPEL repository which you have just been installed with using the following command.

$ rpm -qa | grep epel
epel-release-8-14.el8.noarch

2.) Check Available PHP Version

After we’ve successfully install both software repository, then you need to check the available PHP version on your node system. Simply run the following command to make a list of available PHP on the screen which can be installed futhermore.

$ dnf module list php
Last metadata expiration check: 0:02:22 ago on Tue 15 Mar 2022 08:20:34 AM UTC.
AlmaLinux 8 - AppStream
Name Stream Profiles Summary
php 7.2 [d] common [d], devel, minimal PHP scripting language
php 7.3 common [d], devel, minimal PHP scripting language
php 7.4 common [d], devel, minimal PHP scripting language
Remi's Modular repository for Enterprise Linux 8 - x86_64
Name Stream Profiles Summary
php remi-7.2 common [d], devel, minimal PHP scripting language
php remi-7.3 common [d], devel, minimal PHP scripting language
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

As you can see above that there are two software repositories which provide PHP installation from the version 7.2 to 7.4 on AppStream repository and PHP 7.2 to PHP 8.1 on the REMI repository. From this step simply ignore AlmaLinux 8 – AppStream repository, although they offer official software repository to install any version of PHP on your node.

READ:  How To Install and Configure Kubernetes on Red Hat Enterprise Linux 8.5 (RHEL)

Kindly use “Remi’s Modular repository for Enterprise Linux 8 – x86_64” to install your preferred PHP version on your VPS, Cloud or Bare Metal. Since on the AppStream repository only available PHP 7.4 as the latest stable release. According to the official PHP website, there are three PHP versions which currently have active and security support, including PHP 7.4, PHP 8.0 and PHP 8.1.

Currently Supported PHP Version
Currently Supported PHP Version

Basically each release branch of PHP version is getting two-year full support from its initial stable release. Bugs fix and security maintenance will be done during this period, where all security issues and bugs are reported and all fixed during this years. It come on regular point releases of PHP Update. After each PHP branch reaches its full two-year active support, then each PHP branch will get extra support for critical security maintenance until one year, based on the number of reports.

After three years of active and security supports, each PHP branch will reaches its end of life and will no longer get any support. You can see the above screenshots.

3.) Enable Preferred PHP Version via REMI Software Repository

Then let’s install one of the available PHP version on your node. But before doing it, make sure to enable your preferred PHP branch which you want to install on your node. Simply use one of the following available command.

$ dnf module enable php:remi-7.4
$ dnf module enable php:remi-8.0
$ dnf module enable php:remi-8.1

4.) Let’s Install PHP 8.1-FPM Along with its Extensions

From this step we will stick to PHP 8.1-FPM, and install it on my node. You can try it as well on your machine. Currently PHP 8.1 is the newer version and the latest stable release available from the official PHP vendors. Freely use it if you want to run single PHP version on your machine.

READ:  How To Install MultiPHP-FPM (PHP 7.4, PHP 8.0, & PHP 8.1) on Debian 11 "bullseye"

Run the following command to install PHP 8.1 with FastCGI Process Manager (FPM) and all the required PHP extensions on your node server.

$ dnf module enable php:remi-8.1
$ 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

5.) Check and Verify Installed Version

$ php -v
PHP 8.1.3 (cli) (built: Feb 16 2022 01:00:24) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies

6.) Enable and Start PHP-FPM Service

Lastly, simply enable and start PHP-FPM Service or Daemon on your node. Use the following command to run it…

$ systemctl enable php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
$ systemctl start php-fpm.service

Don’t forget to check the status of service or daemon for PHP-FPM using the following command.

$ systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-03-15 09:38:22 UTC; 7s ago
Main PID: 44655 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 5399)
Memory: 34.5M
CGroup: /system.slice/php-fpm.service
├─44655 php-fpm: master process (/etc/php-fpm.conf)
├─44656 php-fpm: pool www
├─44657 php-fpm: pool www
├─44658 php-fpm: pool www
├─44659 php-fpm: pool www
└─44660 php-fpm: pool www

Mar 15 09:38:22 almalinux-1cpu-1gb-sg-sin1 systemd[1]: Starting The PHP FastCGI Process Manager...
Mar 15 09:38:22 almalinux-1cpu-1gb-sg-sin1 systemd[1]: Started The PHP FastCGI Process Manager.

Good jobs… !!! We’ve successfully on installing and configuring PHP 8.1 with FastCGI Process Manager (FPM) on the single node machine.

Leave a Comment