May 26, 2026
Tutorials

How to Install LEMP Stack on AlmaLinux 10 with NGINX, MySQL, and PHP (Complete Setup Guide)

How to install lemp stack on AlmaLinux 10

Installing LEMP (LAMP) on AlmaLinux 10 is one of the best ways to install a high-performance web application on Linux. LEMP stack is the combination of Linux, NGINX, MySQL, and PHP in order to provide a fast, secure, and scalable web hosting environment for modern websites and applications.

The AlmaLinux 10 distribution is gaining popularity with enterprises due to its long-term stability, RHEL compatibility, security, and package management features. AlmaLinux can be used in combination with NGINX, MySQL, and PHP to host WordPress, Laravel applications, cloud-native web deployments, eCommerce websites, and APIs.

In this step-by-step tutorial, you will install the full LEMP stack on AlmaLinux 10 and configure the NGINX web server, MySQL database, PHP, PHP-FPM, and configure the firewall.

Table of Content

What Is a LEMP Stack?

LEMP stack is a widely used web development stack for dynamic websites and web applications to be hosted using open source technologies.

LEMP stands for:

  • Linux – Operating system
  • NGINX – Web server
  • MySQL – Database server
  • PHP – Server-side scripting language

The LEMP stack replaces the traditional LAMP stack with NGINX, a high-performance, low-resource, and highly scalable web server.

The LEMP stack is commonly used in modern web applications, such as websites built with WordPress, PHP applications, REST APIs, cloud VPS hosting, enterprise web servers, and frameworks like Laravel and Symfony.

Why Use AlmaLinux 10 for a LEMP Stack?

AlmaLinux 10 is an enterprise-stable and secure version of RHEL, with no modifications necessary to make it compatible.

The AlmaLinux 10 platform makes running a LEMP stack more convenient than ever before, offering long-term support for Linux, enterprise-grade security patches, a solid package system, deep integration with SELinux, server optimization, great VPS and cloud support, and highly stable DNF package management for production workloads.

AlmaLinux is lightweight, stable, and suitable for production-level web hosting.

Prerequisites

Here are some prerequisites for installing the LEMP stack:

How to Install LEMP Stack on AlmaLinux 10 for NGINX, MySQL, and PHP Hosting

The LEMP stack on AlmaLinux 10 combines NGINX, MySQL, and PHP to create a secure and scalable Linux web hosting environment for WordPress, Laravel, and modern web applications.

Step 1: Install NGINX on AlmaLinux 10

NGINX is a fast web server that is used to power websites, APIs, reverse proxy services, and load-balanced applications.

Install NGINX:

sudo dnf install nginx -y

  sudo dnf install nginx -y

Enable and start the NGINX service:

sudo systemctl enable nginx

sudo systemctl start nginx

sudo systemctl enable nginx

Check the status of the service:

sudo systemctl status nginx

sudo systemctl status nginx

Step 2: Configure Firewall for NGINX

Enable traffic for HTTP and HTTPS in the AlmaLinux firewall.

Allow HTTP:

sudo firewall-cmd –permanent –add-service=http

  sudo firewall-cmd --permanent --add-service=http

Allow HTTPS:

sudo firewall-cmd –permanent –add-service=https

  sudo firewall-cmd --permanent --add-service=https

Reload the firewall:

sudo firewall-cmd –reload

  sudo firewall-cmd --reload

Verify firewall services:

sudo firewall-cmd –list-services

  sudo firewall-cmd --list-services

Step 3: Test the NGINX Web Server

Go to a web browser and type your server IP address:

http://your-server-ip

  http://your-server-ip

If NGINX has been installed properly, then the default NGINX welcome page will appear.

You can also check locally with:

curl http://localhost

  curl http://localhost

Step 4: Install MySQL Server on AlmaLinux 10

MySQL is one of the most popular relational database management systems (RDBMS) used for Linux Web Hosting.

Install MySQL server:

sudo dnf install mysql-server -y

  sudo dnf install mysql-server -y

Run the following commands to enable and start MySQL:

sudo systemctl enable mysqld

sudo systemctl start mysqld

sudo systemctl enable mysqld

Check if the MySQL service is running:

sudo systemctl status mysqld

sudo systemctl status mysqld

Step 5: Secure the MySQL Installation

Run the MySQL secure installation script:

sudo mysql_secure_installation

  sudo mysql_secure_installation

The MySQL secure installation script is used to help set the MySQL root password, to remove anonymous users, to disable remote root login, to remove test databases, and to improve the overall security of the database server in a production environment.

Do use a strong password for your database in production environments.

Step 6: Install PHP on AlmaLinux 10

WordPress, Laravel, Drupal, Magento, and other web apps use PHP as their server-side language.

Install PHP and required extensions:

sudo dnf install php php-fpm php-mysqlnd php-cli php-gd php-mbstring php-xml php-curl php-zip -y

  sudo dnf install php php-fpm php-mysqlnd php-cli php-gd php-mbstring php-xml php-curl php-zip -y

Specify the PHP version:

php -v

  php -v

Step 7: Configure PHP-FPM

NGINX uses PHP-FPM to process PHP requests. Enable & start PHP-FPM:

sudo systemctl enable php-fpm

sudo systemctl start php-fpm

sudo systemctl enable php-fpm

Check PHP-FPM status:

sudo systemctl status php-fpm

sudo systemctl status php-fpm

Modify the PHP-FPM configuration:

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

Find these lines:

user = apache

group = apache

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

Replace them with:

user = nginx

group = nginx

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

Save the file and restart PHP-FPM:

sudo systemctl restart php-fpm

sudo systemctl restart php-fpm

Step 8: Configure NGINX for PHP Processing

Edit the default NGINX configuration:

sudo nano /etc/nginx/conf.d/default.conf

Add the following configuration:

server {

listen 80;

server_name _;

root /usr/share/nginx/html;

index index.php index.html;

location / {

try_files $uri $uri/ =404;

}

location ~ \.php$ {

include fastcgi_params;

fastcgi_pass unix:/run/php-fpm/www.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}

}

/etc/nginx/conf.d/default.conf

Test the NGINX configuration:

sudo nginx -t

  sudo nginx -t

If it appears to be correct syntax, restart NGINX:

sudo systemctl restart nginx

sudo systemctl restart nginx

Step 9: Test PHP Processing on NGINX

Write a PHP test file:

sudo nano /usr/share/nginx/html/info.php

Include the following information:

<?php

phpinfo();

?>

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

Save the file and open it in a web browser:

The PHP information page will display if PHP is set up properly.

http://your-server-ip/info.php

  http://your-server-ip/info.php

To secure the file, remove the file after testing:

sudo rm -f /usr/share/nginx/html/info.php

  sudo rm -f /usr/share/nginx/html/info.php

Step 10: Enable SELinux Permissions for NGINX and PHP

AlmaLinux 10 is based on SELinux, which is a higher level of security for Linux operating systems.

Turn on NGINX network connections:

sudo setsebool -P httpd_can_network_connect 1

  sudo setsebool -P httpd_can_network_connect 1

Restore correct file permissions:

sudo restorecon -Rv /usr/share/nginx/html

  sudo restorecon -Rv /usr/share/nginx/html

SELinux can enhance the security of the server against unauthorized access and application exploits.

Common LEMP Stack Commands on AlmaLinux 10

Here is a list of some commonly used commands for LEMP Stack on AlmaLinux 10.

Task

Command

Install NGINX

sudo dnf install nginx -y

Install MySQL

sudo dnf install mysql-server -y

Install PHP

sudo dnf install php php-fpm php-mysqlnd -y

Start NGINX

sudo systemctl start nginx

Start MySQL

sudo systemctl start mysqld

Start PHP-FPM

sudo systemctl start php-fpm

Test NGINX config

sudo nginx -t

Reload firewall

sudo firewall-cmd –reload

Security a LEMP Stack – Expert DevOps Practices

Keep Packages Updated

Keep NGINX, PHP, and MySQL packages up to date for security fixes.

Use HTTPS Encryption

Secure, HTTPS connections with SSL Certificates via Let’s Encrypt.

Disable Unused Services

Use only services that are necessary for the applications.

Use Strong Database Passwords

Use strong passwords and minimum privileges for MySQL accounts.

Enable Firewall Protection

Use firewalld to permit only network traffic that is necessary.

Monitor Server Logs

Check NGINX and MySQL logs periodically for anything amiss.

Why the LEMP Stack Is Popular for Modern Web Hosting

The LEMP stack is widely used because it provides excellent performance, lower memory usage, and strong scalability.

NGINX handles concurrent connections more efficiently than many traditional web servers, making it ideal for:

  • High-traffic websites
  • WordPress hosting
  • Cloud applications
  • API servers
  • eCommerce platforms
  • VPS hosting
  • Containerized applications

Combined with PHP and MySQL, the LEMP stack offers a reliable foundation for modern web development.

Conclusion

Install the LEMP stack on AlmaLinux 10 by setting up NGINX, MySQL, and PHP to create a fast, secure, and production-ready Linux web hosting environment for WordPress, Laravel, and modern web applications. This setup is suitable for WordPress hosting, Laravel development, APIs, enterprise web applications, and cloud deployments.

Whether you are a beginner learning Linux server administration or an experienced DevOps engineer deploying production infrastructure, mastering the LEMP stack on AlmaLinux 10 is an essential skill for modern web hosting and application management.

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video