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:10:10 ago on Thu May 29 18:11:07 2025.
Dependencies resolved.
=============================================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================================
Installing:
nginx x86_64 2:1.26.3-1.el10 appstream 36 k
Installing dependencies:
almalinux-logos-httpd noarch 100.3-2.el10_0 appstream 18 k
nginx-core x86_64 2:1.26.3-1.el10 appstream 659 k
nginx-filesystem noarch 2:1.26.3-1.el10 appstream 11 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
Created symlink '/etc/systemd/system/multi-user.target.wants/nginx.service' → '/usr/lib/systemd/system/nginx.service'.
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
Active: active (running) since Thu 2025-05-29 18:21:25 UTC; 144ms ago
Invocation: e1bca6d3688042c1a8613c031e546e14
Main PID: 1482 (nginx)
Tasks: 3 (limit: 23188)
Memory: 2.8M (peak: 3.1M)
CPU: 24ms
CGroup: /system.slice/nginx.service
├─1482 "nginx: master process /usr/sbin/nginx"
├─1483 "nginx: worker process"
└─1484 "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
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:22:35 ago on Thu May 29 18:11:07 2025.
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 noarch 3:10.11.11-1.el10 appstream 261 k
mysql-selinux noarch 1.0.13-2.el10 appstream 37 k
perl-AutoLoader noarch 5.74-512.1.el10_0 appstream 21 k
perl-B
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
Created symlink '/etc/systemd/system/mysql.service' → '/usr/lib/systemd/system/mariadb.service'.
Created symlink '/etc/systemd/system/mysqld.service' → '/usr/lib/systemd/system/mariadb.service'.
Created symlink '/etc/systemd/system/multi-user.target.wants/mariadb.service' → '/usr/lib/systemd/system/mariadb.service'.
● mariadb.service - MariaDB 10.11 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
Active: active (running) since Thu 2025-05-29 18:46:19 UTC; 153ms ago
Invocation: ee3aea4c563048b8b9500e2d670b07b6
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 2293 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 12 (limit: 23188)
Memory: 204.3M (peak: 230.3M)
CPU: 500ms
CGroup: /system.slice/mariadb.service
└─2293 /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-05-29 18:57:12 UTC; 1h 9min ago
Invocation: a05c60c439d64e158b5dbd5e769b2a03
Main PID: 2784 (php-fpm)
Status: "Processes active: 0, idle: 5, Requests: 1, slow: 0, Traffic: 0.00req/sec"
Tasks: 6 (limit: 23188)
Memory: 15M (peak: 15.2M)
CPU: 179ms
CGroup: /system.slice/php-fpm.service
├─2784 "php-fpm: master process (/etc/php-fpm.conf)"
├─2790 "php-fpm: pool www"
├─2791 "php-fpm: pool www"
├─2792 "php-fpm: pool www"
├─2794 "php-fpm: pool www"
└─2798 "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@server ~]# php -v
PHP 8.4.7 (cli) (built: May 6 2025 12:31:58) (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.
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