, ,

A Comprehensive Guide to Installing LEMP Stack on AlmaLinux 8

In this comprehensive guide, we’ll walk you through the step-by-step process of installing the LEMP stack on AlmaLinux 8. The LEMP stack comprises Linux as the operating system, Nginx as the web server, MariaDB as the database, and PHP for dynamic web processing. Follow along to set up a robust environment for serving dynamic web pages and applications written in PHP.

Before diving into the installation, ensure you have the following:

  • AlmaLinux installed on a dedicated or cloud server.
  • Root user access or a normal user with administrative privileges.

Installation Steps:

1. Install Nginx Web Server:

Begin by installing Nginx using the following commands:

# dnf install nginx -y

After installation, start and enable the Nginx server, and configure the firewall to allow HTTP and HTTPS traffic:

# systemctl start nginx && systemctl enable nginx
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload

2. Install MariaDB Database:

Configure the MariaDB repository, update it, and install MariaDB 10.5:

# vi /etc/yum.repos.d/MariaDB.repo
# dnf update -y
# dnf install mariadb-server -y

After installation, start and enable MariaDB, and secure the installation:

# systemctl start mariadb.service && systemctl enable mariadb.service
# mysql_secure_installation

3. Install PHP:
Add EPEL and Remi repositories, choose the PHP version, and install PHP:

# dnf install epel-release -y
# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
# dnf module reset php -y
# dnf module enable php:remi-8.0 -y
# dnf install php php-fpm -y

Verify the PHP installation:

# php -v

Congratulations! You’ve successfully installed the LEMP stack on AlmaLinux 8, creating a powerful foundation for hosting dynamic web content. Feel free to reference the official documentation for AlmaLinux, Nginx, MariaDB, and PHP for additional information.