Install php-fpm with Nginx

Please take a look how to setup nginx standalone using Almalinux 8 first. Then we will proceed to install php-fpm under this VPS which nginx pre-installed. By default php version shipped with Almalinux 8 is php7.2. However, we need to use php8 at least for stable production.

# yum module list php
Last metadata expiration check: 0:25:47 ago on Thu Feb  8 08:21:27 2024.
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
php              8.0                common [d], devel, minimal            PHP scripting language

If you see above the tag [d] means default. We will make php8.0 to become default tag using module set. We are using remi repo and comes with php-fpm module.

dnf module reset php -y
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf module install php:remi-8.0

And the result is here

# php -v
PHP 8.0.30 (cli) (built: Aug  3 2023 17:13:08) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies

Let’s restart some services and make some changes.

systemctl restart nginx
systemctl restart php-fpm
systemctl enable php-fpm

Let’s create a file and verify if php8.0 loaded into nginx.

cd /usr/share/nginx/html
vi info.php

Create phpinfo

<?php phpinfo(); ?>

The result will become this :

Preview php version 8.0 php-fpm

We installed basic php8.0 of remi. If you wish to use for production use, there might some extension php need to be installed. I will give you some reference.

dnf install php-opcache php-mbstring php-mysqli php-gd

Leave a Reply 0

Your email address will not be published. Required fields are marked *