How to Install LEMP Stack on AlmaLinux 10

LEMP is a combination of free, open source software. The acronym LEMP refers to the first letters of Linux (Operating system), Nginx Server, MySQL (database software), and PHP, PERL or Python, principal components to build a viable general purpose web server.

Install Nginx Web Server

First, we will start by installing the Nginx web server. To complete the installation, use the following command:

yum install nginx -y

Output:

[root@vps ~]# yum install nginx -y
Last metadata expiration check: 0:01:38 ago on Thu 19 Jun 2025 03:49:57 PM UTC.
Dependencies resolved.
=============================================================================================================================================================================
 Package                                       Architecture                       Version                                        Repository                             Size
=============================================================================================================================================================================
Installing:
 nginx                                         x86_64                             2:1.26.3-1.el10                                appstream                              33 k
Installing dependencies:
 nginx-core                                    x86_64                             2:1.26.3-1.el10                                appstream                             663 k
 nginx-filesystem                              noarch                             2:1.26.3-1.el10                                appstream                              11 k
 rocky-logos-httpd                             noarch                             100.3-6.el10                                   appstream                              24 k

Transaction Summary
=============================================================================================================================================================================
Install  4 Packages

Once the installation is complete, enable Nginx (to start automatically upon system boot), start the web server and verify the status using the commands below.

systemctl start nginx

systemctl enable nginx

systemctl status nginx

Output:

[root@vps ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/nginx.service.d
             └─php-fpm.conf
     Active: active (running) since Thu 2025-06-19 15:59:16 UTC; 15min ago
 Invocation: 439d25bf37664170b3caaf4c9c3dd535
    Process: 20304 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    Process: 20306 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Process: 20308 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 20309 (nginx)
      Tasks: 3 (limit: 23188)
     Memory: 2.9M (peak: 3.4M)
        CPU: 25ms
     CGroup: /system.slice/nginx.service
             ├─20309 "nginx: master process /usr/sbin/nginx"
             ├─20310 "nginx: worker process"
             └─20311 "nginx: worker process"

Check Nginx version,

nginx -v

Output:

[root@vps ~]# nginx -v
nginx version: nginx/1.26.3

To make your pages available to public, you will have to edit your firewall rules to allow HTTP requests on your web server by using the following commands.

firewall-cmd --permanent --zone=public --add-service=http 

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload

Output:

[root@vps ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@vps ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@vps ~]# firewall-cmd --reload
success

Verify that the web server is running and accessible by accessing your server’s IP address.

From your browser,

http://IP_address

Note: Replace IP_Address with actual IP Address

images

We need to make user nginx as the owner of web directory. By default it’s owned by the root user.

chown nginx:nginx /usr/share/nginx/html -R

Install MariaDB Server

MariaDB is a popular database server. The installation is simple and requires just a few steps as shown.

yum install mariadb-server mariadb -y

Output:

[root@vps ~]# yum install mariadb-server mariadb -y
Last metadata expiration check: 0:03:47 ago on Thu 19 Jun 2025 03:49:57 PM UTC.
Dependencies resolved.
=============================================================================================================================================================================
 Package                                              Architecture                   Version                                         Repository                         Size
=============================================================================================================================================================================
Installing:
 mariadb                                              x86_64                         3:10.11.11-1.el10                               appstream                         1.6 M
 mariadb-server                                       x86_64                         3:10.11.11-1.el10                               appstream                         9.9 M
Installing dependencies:
 checkpolicy                                          x86_64                         3.8-1.el10                                      appstream                         357 k
 libaio                                               x86_64                         0.3.111-22.el10                                 baseos                             24 k
 mariadb-common                                       noarch                         3:10.11.11-1.el10                               appstream                          35 k
 mariadb-connector-c                                  x86_64                         3.4.4-1.el10                                    baseos                            206 k
 mariadb-connector-c-config                           noarch                         3.4.4-1.el10                                    baseos                            8.9 k
 mariadb-errmsg       

Once the installation is complete, enable MariaDB (to start automatically upon system boot), start the MariaDB and verify the status using the commands below.

systemctl start mariadb

systemctl enable mariadb

systemctl status mariadb

Output:

[root@vps ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.11 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
     Active: active (running) since Thu 2025-06-19 15:54:39 UTC; 21min ago
 Invocation: c4980a57d2cf4f20979b75ad1e47986d
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 19739 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 8 (limit: 23188)
     Memory: 204.6M (peak: 231.7M)
        CPU: 833ms
     CGroup: /system.slice/mariadb.service
             └─19739 /usr/libexec/mariadbd --basedir=/usr

Finally, you will want to secure your MariaDB installation by issuing the following command.

mysql_secure_installation

Output:

[root@vps ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!

...

Once secured, you can connect to MySQL and review the existing databases on your database server by using the following command.

mysql -e "SHOW DATABASES;" -p

Output:

[root@vps ~]# mysql -e "SHOW DATABASES;" -p
Enter password: 
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
[root@vps ~]#

Install PHP 8.4

To begin, enable the CRB (CodeReady Builder) repository, which provides libraries required by some third-party packages,

dnf config-manager --set-enabled crb

Next, install the EPEL repository. This adds additional useful packages that aren't available in the default AlmaLinux repositories,

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

Now, install the Remi repository, which maintains the latest PHP versions for RHEL-based systems,

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

Switch the system's PHP module to Remi’s PHP 8.4 stream to ensure packages are pulled from the correct source,

dnf module switch-to php:remi-8.4

Enable and install the PHP 8.4 module,

dnf module install php:remi-8.4

By default, PHP-FPM runs as the apache user. Since we are using Nginx web server, we need to change following line.

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

user = apache
group = apache

Change them to

user = nginx
group = nginx

Once the installation is complete, enable php-fpm (to start automatically upon system boot), start the php-fpm and verify the status using the commands below.

systemctl start php-fpm

systemctl enable php-fpm

systemctl status php-fpm

Output:

[root@vps ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; preset: disabled)
     Active: active (running) since Thu 2025-06-19 15:59:11 UTC; 17min ago
 Invocation: 44219ce8bff1453592f90871bde0ff0d
   Main PID: 20279 (php-fpm)
     Status: "Processes active: 0, idle: 5, Requests: 1, slow: 0, Traffic: 0.00req/sec"
      Tasks: 6 (limit: 23188)
     Memory: 9.7M (peak: 9.9M)
        CPU: 67ms
     CGroup: /system.slice/php-fpm.service
             ├─20279 "php-fpm: master process (/etc/php-fpm.conf)"
             ├─20288 "php-fpm: pool www"
             ├─20289 "php-fpm: pool www"
             ├─20290 "php-fpm: pool www"
             ├─20291 "php-fpm: pool www"
             └─20292 "php-fpm: pool www"

Once changed, need to reload php-fpm

systemctl reload php-fpm

Verify PHP Installation

Check the installed PHP version to confirm success,

php -v

Output:

[root@vps ~]# php -v
PHP 8.4.8 (cli) (built: Jun  3 2025 16:29:26) (NTS gcc x86_64)
Copyright (c) The PHP Group

Restart the Nginx and PHP-FPM.

systemctl restart nginx php-fpm

To create the file use:

echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php

Now again, access http://yourserver-ip-address/info.php. You should see a page similar to below one.

images

Done!


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS