How to install LEPP Stack on RHEL 8

Share on Social Media

Learn how to install the LEPP Stack (Linux, Nginx, PostgreSQL, PHP) on RHEL 8 with our detailed guide. Follow step-by-step instructions to set up and configure your LEPP Stack efficiently on your RHEL 8 system. #centlinux #linux #nginx #postgres #php

What is LEPP Stack?

The LEPP Stack is a powerful and efficient software stack for building and deploying dynamic web applications. Each component of the LEPP Stack plays a crucial role:

  1. Linux: As the underlying operating system, Linux provides stability, security, and performance. It is widely used in server environments due to its robustness and flexibility.
  2. Nginx: Nginx serves as the web server and reverse proxy server. Known for its high performance, scalability, and low resource usage, Nginx is capable of handling a large number of concurrent connections, making it ideal for high-traffic websites and applications.
  3. PostgreSQL: PostgreSQL is an advanced, open-source relational database management system (RDBMS). It is renowned for its robustness, feature set, and standards compliance. PostgreSQL supports complex queries, foreign keys, triggers, and updatable views, among other features. Its ability to handle a wide variety of workloads, from single-machine applications to large internet-facing applications with many concurrent users, makes it a strong choice for database management.
  4. PHP: PHP is a widely-used server-side scripting language designed for web development. It is embedded into HTML and interacts with the database to create dynamic content. PHP’s ease of use, extensive documentation, and large community support make it a popular choice for developing web applications.
How to install LEPP Stack on RHEL 8
How to install LEPP Stack on RHEL 8

Advantages of Using the LEPP Stack

  • Performance: Nginx’s efficiency in handling requests and PostgreSQL’s advanced features contribute to high performance.
  • Scalability: Nginx and PostgreSQL are designed to scale with the demands of high-traffic applications.
  • Flexibility: Each component of the LEPP Stack is highly configurable, allowing you to tailor the environment to specific needs.
  • Security: Linux, Nginx, PostgreSQL, and PHP all have strong security features and best practices to help protect your applications.
  • Community and Support: All components of the LEPP Stack have active communities and extensive documentation, providing support and resources for troubleshooting and optimization.

Use Cases for the LEPP Stack

  • Content Management Systems (CMS): Platforms like Drupal and Joomla can be powered efficiently by the LEPP Stack.
  • E-commerce Applications: The stack can handle complex transactions, user management, and high traffic typical of e-commerce platforms.
  • Custom Web Applications: Developers can build custom web applications with dynamic content, complex queries, and robust backend support.

The LEPP Stack is a reliable and powerful choice for developers looking to create dynamic and scalable web applications.

Recommended Training: SQL and PostgreSQL for Beginners: Become a SQL Expert from Jon Avis

1272712 2a82 14
show?id=oLRJ54lcVEg&bids=1597309

Environment Specification

We have provisioned a RHEL 8 minimal installed virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Red Hat Enterprise Linux (RHEL) 8
  • Hostname – rhel-8-lepp.example.com
  • IP Address – 192.168.116.165/24

A Local YUM repository is also configured, so we can install required packages without having an active Red Hat subscription.

Install PostgreSQL on RHEL 8

Connect with rhel-8-lepp.example.com using ssh as root user.

PostgreSQL Database Server 10.6 is available in our local AppStream repository. Therefore, we can install it using dnf command.

dnf install -y postgresql-server

Initialize PostgreSQL database instance with following command.

postgresql-setup --initdb --unit postgresql

Output:

 * Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

Enable and start PostgreSQL service.

systemctl enable postgresql.service
systemctl start postgresql.service

Verify version of PostgreSQL database.

Due to security, the execution of PostgreSQL commands by root user is not permitted. Therefore, we have to switch user to postgres user to execute PostgreSQL commands.

su - postgres

Check Postgres software version.

postgres --version

Output:

postgres (PostgreSQL) 10.6

PostgreSQL has been installed on Red Hat Enterprise Linux (RHEL) 8.

Install Nginx on RHEL 8

Nginx 1.14 is available in local AppStream repository. Therefore, we are installing it using dnf command.

dnf install -y nginx

Enable and start Nginx service.

systemctl enable nginx.service
systemctl start nginx.service

Allow HTTP service in Linux firewall.

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

Browse URL http://rhel-8-lepp.example.com in a client’s browser.

Nginx Default Page
Nginx Default Page

Nginx web server has been installed on Red Hat Enterprise Linux (RHEL) 8.

Install PHP on RHEL 8

PHP 7.2 is available in local AppStream repository. Therefore, we can install php and relevant packages using dnf command.

dnf install -y php php-mysqlnd php-pdo php-gd php-mbstring php-fpm php-pgsql

Edit php-fpm configurations.

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

Find and set following directives therein.

user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx

Adjust permissions on PHP directories.

chgrp nginx /var/lib/php/{opcache,session,wsdlcache}

Start and enable php-fpm service.

systemctl enable php-fpm.service
systemctl start php-fpm.service

Restart httpd.service to integrate PHP with Nginx web server.

systemctl restart nginx.service

Create a PHP script to check PHP modules.

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

Browse URL http://rhel-8-lemp.example.com/info.php in a client’s browser.

PHPInfo Page
PHPInfo Page

PHP 7.2 has been installed and running on Red Hat Enterprise Linux (RHEL) 8.

Frequently Asked Questions (FAQs)

1. Why is the LEPP Stack considered an alternative to LAMP?

Answer: LEPP replaces Apache (LAMP) with Nginx (for better performance under high traffic) and MySQL/MariaDB with PostgreSQL (for advanced features like JSON support and ACID compliance).


2. What role does PHP-FPM play in the LEPP Stack?

Answer: PHP-FPM (FastCGI Process Manager) processes PHP scripts efficiently with Nginx (which doesn’t natively handle PHP), improving speed and resource usage.


3. Why is PostgreSQL preferred over MySQL in some web applications?

Answer: PostgreSQL offers better scalability, advanced SQL compliance, JSON support, and transactional integrity (ACID), making it ideal for complex applications.


4. How does Nginx differ from Apache in handling web requests?

Answer: Nginx uses an event-driven, asynchronous architecture, handling multiple requests with low memory usage, while Apache relies on threads/processes per connection, which can be heavier.


5. What security practices should you follow when deploying a LEPP Stack?

Answer: Key steps include:

  • Firewall rules (firewalld for ports 80/443).
  • Regular updates (sudo dnf update).
  • Securing PostgreSQL (password authentication, restricting remote access).
  • Disabling PHP execution in sensitive directories.

Final Thoughts

Setting up the LEPP stack (Linux, Nginx, PostgreSQL, and PHP) on RHEL 8 creates a modern, efficient environment for hosting dynamic web applications. In this guide, we covered installing and configuring each component, ensuring they work together seamlessly.

With your LEPP stack now in place, you have a solid, high-performance foundation that combines a lightweight web server with a powerful database backend. To maintain the stability and security of your setup, remember to apply regular updates, harden your configurations, and monitor the system for optimal performance.

From setting up scalable AWS solutions to managing complex Linux environments, I’ve got you covered. Visit my Fiverr profile to get started.

Looking for something?

2 responses to “How to install LEPP Stack on RHEL 8”

  1. Anonymous Avatar
    Anonymous

    Notice that you don't have to change http://www.conf, keept it running on "apache" is perfectly fine, default configuration is designed to work out if the box with Apache or Nginx.

    Additional package (e.g. in EPEL, such as phpMyAdmin, WordPress, …) will rely on this settings

    More, if you change default user, you also need to change used state directory (see php_value directive at the end of the http://www.conf file).

Leave a Reply