How to Install LEMP Stack on AlmaLinux 10
Introduction
The LEMP stack combines Linux, Nginx, MariaDB, and PHP to provide a fast and reliable platform for hosting PHP websites and web applications. Compared to Apache-based environments, Nginx offers better performance under high traffic, while PHP-FPM efficiently handles PHP processing.
This guide shows how to install the latest LEMP stack on a fresh AlmaLinux 10.1 server. You’ll configure the required repositories, install Nginx 1.28.2, PHP 8.5.4, and MariaDB 11.8.6, then verify the installation using your server’s public IP address.
Prerequisites
Before you begin, make sure you have:
- A fresh AlmaLinux 10 server
- Root or sudo privileges
- A public IPv4 address
- Port 80 is open in the firewall
- At least 2 vCPUs, 4 GB RAM, and 50 GB of storage
Verify the Operating System
Before installing the LEMP stack, verify that your server is running AlmaLinux 10.
cat /etc/os-release
The output should display AlmaLinux 10.1 or a later AlmaLinux 10 release.
Update the Server and Install Base Utilities
Update the system and install the required utilities before adding third-party repositories.
dnf -y update dnf -y install epel-release dnf-plugins-core curl ca-certificates gnupg2 tar unzip

Once the update completes, continue by configuring the official software repositories.
Add the Official Repositories
Configure the official repositories for Nginx, PHP, and MariaDB to install the latest stable packages.
Enable the CRB repository and install the Remi repository.
dnf config-manager --set-enabled crb dnf -y install https://rpms.remirepo.net/enterprise/remi-release-10.rpm
Create the Nginx stable repository.
cat >/etc/yum.repos.d/nginx.repo <<'EOF' [nginx-stable] name=nginx stable repo baseurl=https://nginx.org/packages/rhel/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true EOF
Install the MariaDB 11.8 repository.
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version=mariadb-11.8
Disable the unused MaxScale repository.
dnf config-manager --set-disabled mariadb-maxscale
The repositories are now ready, allowing DNF to install the latest package versions used in this guide.
Install Nginx, PHP 8.5, and MariaDB
With the repositories configured, install Nginx, PHP 8.5, PHP-FPM, the required PHP extensions, and MariaDB.
dnf --disablerepo=mariadb-maxscale -y install \ nginx \ php85 php85-php-cli php85-php-fpm php85-php-mysqlnd php85-php-xml php85-php-mbstring php85-php-pecl-zip \ MariaDB-server MariaDB-client
After the installation completes, all required LEMP components will be available on the server.
Configure Nginx, PHP-FPM, and MariaDB
Create a new Nginx server configuration. Replace YOUR_SERVER_IP with your server’s public IP address.
server {
listen 80;
listen [::]:80;
server_name YOUR_SERVER_IP;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/opt/remi/php85/run/php-fpm/www.sock;
fastcgi_index index.php;
}
}
Save the configuration file, then create a simple PHP test page.
echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php
Enable and start the required services.
systemctl enable --now nginx php85-php-fpm mariadb
Verify the Nginx configuration.
nginx -t
If the configuration test is successful, reload Nginx.
systemctl reload nginx
The web server is now configured to process PHP files through PHP-FPM.
Verify the Installed Versions
Verify that Nginx, PHP, and MariaDB were installed successfully.
nginx -v /opt/remi/php85/root/usr/bin/php -v mariadb --version systemctl is-active nginx php85-php-fpm mariadb

You should see output similar to the following:
- Nginx 1.28.2
- PHP 8.5.4
- MariaDB 11.8.6
All three services should return active.
Test the LEMP Stack
Open your server’s public IP address in a web browser.
http://YOUR_SERVER_IP
If the PHP information page appears, the installation was successful and the LEMP stack is working correctly.
Troubleshooting
If PHP is not processed correctly, verify that PHP-FPM is running.
systemctl status php85-php-fpm
If Nginx returns a 502 Bad Gateway error, make sure the PHP-FPM socket matches the following path:
/var/opt/remi/php85/run/php-fpm/www.sock
If the PHP command is unavailable, use the full binary path.
/opt/remi/php85/root/usr/bin/php -v
Conclusion
Congratulations! You have successfully installed the LEMP stack on AlmaLinux 10 with Nginx 1.28.2, PHP 8.5.4, and MariaDB 11.8.6.
Your server is now ready to host PHP websites, web applications, and APIs. To keep the system secure and up to date, regularly install the latest package updates.



