How to Install PHP for LEMP on AlmaLinux OS
Leave a comment on How to Install PHP for LEMP on AlmaLinux OS
Are you building a LEMP stack (Linux, Nginx, MySQL, PHP) on AlmaLinux? One of the most essential components you’ll need is PHP — the scripting language that powers popular platforms like WordPress, Joomla, and countless other web applications.

In this article, we’ll walk you through how to install and configure PHP for your LEMP stack on AlmaLinux. Whether you’re preparing to launch a blog, an e-commerce site, or a custom-built web app, this guide will help you get PHP up and running quickly and securely.
Why Use PHP with LEMP on AlmaLinux?
PHP remains one of the most widely used server-side scripting languages on the web. When combined with a LEMP stack, you get:
- Performance and efficiency — Nginx serves static content fast, while PHP handles dynamic scripts.
- Compatibility — Most CMS platforms, including WordPress, require PHP.
- Flexibility — Large library of extensions and modules to expand functionality.
- Active community support — Frequent updates and improvements.
- Stability with AlmaLinux — Enterprise-grade, long-term supported operating system.
By pairing PHP with AlmaLinux and Nginx, you’ll have a modern, stable, and powerful environment for hosting websites and web applications.
Prerequisites
Before we begin, ensure the following:
- You have a VPS running AlmaLinux OS
- Root or sudo access to your server
- An SSH client (e.g., PuTTY, Bitvise)
- Nginx and MariaDB/MySQL already installed as part of your LEMP stack
👉 Don’t have a server yet? Order a RackNerd VPS and enjoy lightning-fast performance, 24×7 support, and affordable pricing.
Step-by-Step: Install PHP on AlmaLinux for LEMP
Follow these steps in your terminal to install and configure PHP.
Step 1: Update Your System
Start by making sure your server packages are up to date:
dnf update -y

Step 2: Enable Required Repositories
Install EPEL and Remi repositories, along with yum-utils:
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y

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

dnf install yum-utils -y

Reset and enable the PHP 8.0 module:
dnf module reset php
dnf module install php:remi-8.0


Step 3: Install PHP and Extensions
Install PHP along with commonly used extensions for web apps like WordPress:
dnf install php-{fpm,gd,json,mbstring,mysqlnd,xml,xmlrpc,opcache,cli,zip,soap,intl,bcmath,curl,ssh2} -y

Step 4: Start and Enable PHP-FPM
Enable PHP-FPM (FastCGI Process Manager), which allows Nginx to process PHP scripts:
systemctl start php-fpm && systemctl enable php-fpm

Verify the status:
systemctl status php-fpm

Step 5: Configure PHP-FPM for Nginx
First, create a backup of the default configuration file:
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.bak

Open the configuration file with Nano:
dnf install nano -y

nano /etc/php-fpm.d/www.conf

Inside the file:
- Change user and group from apache to nginx
- Update the listen directive to:
/run/php-fpm/php-fpm.sock
- Replace “nobody” values with nginx and remove the semicolons to enable the directives
- Comment out (disable) the following line by adding a semicolon:
;listen.acl_users = apache,ngin
Save changes with CTRL+O, press ENTER, and exit with CTRL+X.
Step 6: Clean Up Old Config Files
Remove unneeded default PHP configuration files for Nginx:
rm -rf /etc/nginx/conf.d/php-fpm.conf && rm -rf /etc/nginx/default.d/php.conf

Step 7: Restart PHP-FPM and Nginx
Apply your changes by restarting the services:
systemctl restart {php-fpm,nginx}
Verify again that both are running:
systemctl status {php-fpm,nginx}

If everything looks good, PHP is now fully integrated with your LEMP stack on AlmaLinux.
What’s Next?
With PHP installed and configured, you’re ready to:
- Install WordPress or another CMS
- Build custom PHP applications
- Secure and optimize your PHP settings for production
RackNerd VPS Hosting for LEMP Stacks
At RackNerd, our VPS hosting is designed to power modern LEMP stacks:
- Full root access
- Multiple OS choices including AlmaLinux
- SSD RAID-10 storage
- 1Gbps network speeds
- 24/7 support from real experts
Whether you’re hosting a personal blog, a business website, or a web application, RackNerd VPS ensures speed, security, and reliability.
👉 Order a RackNerd VPS today and start building your optimized LEMP environment with PHP support.
Conclusion
Installing PHP on AlmaLinux for a LEMP stack is straightforward when you follow the right steps. With your server now ready, you can confidently deploy WordPress or any PHP-based web application.
Take your hosting setup to the next level with RackNerd’s reliable VPS infrastructure — built to support developers, businesses, and webmasters around the globe.