Learn how to install LEMP Stack on RHEL 8 with our step-by-step guide. Follow detailed instructions to set up and configure your LEMP Stack for optimal performance on RHEL 8. #centlinux #linux #nginx #mysql #php
LEMP is a popular software stack. LEMP is named after the first letter of four software that forms the Stack i.e. Linux, Nginx, MySQL and PHP. LEMP is used to deploy PHP based web applications with MySQL database backend. LEMP is a variation of original LAMP stack, where Apache HTTP Server is replaced by Nginx Web Server.
The LEMP Stack is a popular open-source software stack used for creating and managing web applications. It’s an acronym that stands for:
In this article, we will install LEMP stack on RHEL 8 server. To achieve this goal, we are installing MariaDB database, Nginx web server and PHP language support on a Red Hat Enterprise Linux (RHEL) 8 server.
Recommended Online Training: Learn Bash Shell in Linux for Beginners
We have installed a Red Hat Enterprise Linux (RHEL) 8 virtual machine with following specifications.
We have also configured a Local YUM repository on our RHEL 8 server, so we can install required software without an active Red Hat subscription.
Connect with rhel-8-lemp.example.com using ssh as root user.
MariaDB Server 10.3 is available in RHEL 8 local AppStream repository. Therefore, we can install it easily using dnf command.
# dnf install -y mariadb-server
Enable and start MariaDB service.
# systemctl enable mariadb.service 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. # systemctl start mariadb.service
Configure and secure MariaDB database instance.
# 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 you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Nginx 1.14 is available in local AppStream repository. Therefore, we can install it using dnf command.
# yum install -y nginx
Enable and start Nginx service.
# systemctl enable nginx.service Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service â /usr/lib/systemd/system/nginx.service. # systemctl start nginx.service
Allow HTTP service in Linux firewall.
# firewall-cmd --permanent --add-service=http success # firewall-cmd --reload success
Open URL http://rhel-8-lemp.example.com in a client’sweb browser.
Nginx web server is installed and working fine on our Linux server.
PHP 7.2 is available in local AppStream repository. Therefore, we can install it using dnf command.
# dnf install -y php php-mysqlnd php-pdo php-gd php-mbstring php-fpm
Edit php-fpm configurations.
# vi /etc/php-fpm.d/www.conf
Find and set following settings therein.
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
Start and enable php-fpm service.
# systemctl enable php-fpm.service Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service â /usr/lib/systemd/system/php-fpm.service. # systemctl start php-fpm.service
Restart Nginx service to integrate PHP with Nginx.
# systemctl restart nginx.service
Create a PHP file to check information about installed PHP modules.
# echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php
Open URL http://rhel-8-lemp.example.com/info.php in a web browser.
PHP 7.2 has been installed and running on our Linux server.
Read Also: How to install LEMP on Ubuntu 14
If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.
If you found this guide on installing the LEMP Stack on RHEL 8 useful and need additional help with server setup or technical support, consider reaching out for professional assistance. Visit my Fiverr profile for expert services in server configuration, database management, and more. Let’s work together to achieve your goals!
Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…
Discover how to change Apache port in Linux easily. Follow our simple guide to modify…
Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…
Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…
Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…
Explore the ultimate guide to VPS servers and learn everything about Virtual Private Servers, including…
This website uses cookies.