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
Table of Contents
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:
- 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.
- 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.
- 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.
- 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.

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

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.
300 Pcs Stickers for Kids, Cute Water Bottle Vinyl Waterproof Laptop Stickers for Students Gifts School Supplies Classroom Teacher Prizes Sticker Pack for Kids Girls Teens
$7.99 (as of May 15, 2025 16:15 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)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 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.

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.
Getting Started Becoming a Master Hacker: Hacking is the Most Important Skill Set of the 21st Century!
$39.99 (as of May 15, 2025 16:15 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)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.
Leave a Reply
You must be logged in to post a comment.