Skip to main content

LEMP Stack Deep Dive

Course

Intro Video

Photo of Michael Christian

Michael Christian

Course Development Director in Content

Length

12:28:41

Difficulty

Intermediate

Videos

28

Hands-on Labs

9

Course Details

In this course, you will gain a better understanding of the LEMP stack through lessons and hands-on labs. You will learn how to install a LEMP stack on both RHEL and Ubuntu Linux, perform basic configuratiin of NGINX, secure MariaDB and even deploy a PHP application on a LEMP stack. When you have finished the course you will have the skills necessary to build your own LEMP stack.

Syllabus

Course Introduction

Getting Started

Upcoming Lesson: About the Course / Prerequisites

Lesson Description:

In this lesson, we are going to preview the LEMP Stack Deep Dive course. We will talk about the scope of the course and what skills and experience you should bring to the course. When you finish this lesson you should have a good understanding of what the course is about.

Upcoming Lesson: About the Training Architect

Lesson Description:

Get to know your Training Architect, Tom Dean.

Upcoming Lesson: Big State College - A Case Study

Lesson Description:

In this lesson, you will be introduced to the scenario for the labs in the LEMP Stack Deep Dive course, Big State College.

Introduction to the LEMP Stack

Upcoming Lesson: What is the LEMP Stack?

Lesson Description:

In this lesson, you will be introduced to the LEMP Stack. We will cover web stacks, the LAMP Stack, and the evolution toward the LEMP Stack. We will talk about the role of Linux in the LEMP Stack and how to choose a distribution. When this lesson is complete, we will have a better understanding of what the LEMP Stack is and a high-level understanding of how one is put together.

Upcoming Lesson: NGINX - The Engine of the Stack

Lesson Description:

The web server is the heart of any web stack. It's how the outside world accesses the data and applications on the site(s) living on the stack. In this lesson, we will take a look at NGINX, the new kid on the block in high-performance, flexible web servers. We'll take a look at the origin of NGINX, it's features, the additional features that NGINX Plus offers, and compare NGINX with the Apache Web Server. Upon completion of this lesson, you will have a solid high-level understanding of NGINX.

Upcoming Lesson: Why MariaDB?

Lesson Description:

The database is an important part of the web stack. For years, MySQL was the foundation of the LAMP Stack. The LEMP Stack brings us MariaDB, the next evolution of MySQL. In this lesson, we will learn what the role of a database is in the web stack, the history of MySQL and MariaDB, MySQL and MariaDB's similarities and differences, and options for MariaDB in the cloud. Upon completion of this lesson, you will have a good high-level understanding of MariaDB.

Upcoming Lesson: PHP - Follow the Script

Lesson Description:

PHP is the part of the LEMP Stack that makes rich, interactive websites and applications possible. In this lesson, we will learn what PHP is and about PHP's history. We will also examine how PHP fits into the LEMP Stack and how PHP code is processed using PHP-FPM. We will take a look at some sample PHP code and will also look at the pros and cons of PHP. Upon completion of this lesson, you will have a good high-level understanding of PHP and its role in the LEMP Stack.

Linux - The Foundation of the Stack

Installing a LEMP Stack on Linux

Installing LEMP on RHEL 8

00:09:54

Lesson Description:

Before you build a house, you have to lay the foundation. And before you can build a great website or application, you will need a web stack on which to build it. In this lesson, we're going to cover what a web stack and the LEMP Stack are, and how to install the LEMP Stack on RHEL 8. When you finish this lesson, you will know how to install a LEMP Stack on a modern Red Hat Linux distribution. Let's go!

Installing LEMP on Ubuntu Linux

00:10:00

Lesson Description:

Before you build a house, you have to lay the foundation. And before you can build a great website or application, you will need a web stack on which to build it. In this lesson, we're going to cover what a web stack and the LEMP Stack are, and how to install the LEMP Stack on Ubuntu Linux. When you finish this lesson, you will know how to install a LEMP Stack on Ubuntu Linux. Let's go!

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Installing a LEMP Stack on RHEL 8

00:45:00

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Installing a LEMP Stack on Ubuntu Linux

00:45:00

NGINX - The Engine of the Stack

Configuring the NGINX Server

NGINX - Resources and Documentation

00:02:52

Lesson Description:

In this lesson, we are going to introduce you to the nginx.org website. The website is a rich resource and will assist you with installing, configuring, and maintaining your NGINX environment. When this lesson is complete, you should have a better understanding of how the nginx.org website can be a fantastic tool for anyone working with NGINX.

Upcoming Lesson: Basic NGINX Server Configuration

Lesson Description:

In this lesson, we will explore the basic configuration of the NGINX web server. We will look at the /etc/nginx directory, the nginx.conf configuration file, virtual host configuration file locations, how and why we validate NGINX configurations, and how to reload and restart NGINX. When you are finished with this lesson, you will have a basic understanding of how NGINX is configured, and how and why to perform the basic steps to update your NGINX configuration.

Upcoming Lesson: NGINX - Configuring Virtual Hosts

Lesson Description:

In this lesson, we will look at basic virtual host configuration in NGINX. We will review the locations for virtual host configuration files, create and test a new virtual host configuration, and explore troubleshooting errors in virtual host configuration files. When you are done with this lesson, you should be ready to configure your own virtual hosts in NGINX.

Upcoming Lesson: Configuring Custom Error Pages in NGINX

Lesson Description:

In this lesson, we will examine how we configure NGINX to handle custom error pages. We will configure a custom error page for a single error type, as well as for multple error types. When you finish this lesson, you should be able to configure custom error pages in NGINX.

Upcoming Lesson: NGINX - Directives - Upstream / Location / Return

Lesson Description:

In this lesson, we will examine some of the more popular directives in NGINX. We'll cover the upstream, location and return directives, three directives you will use all the time with NGINX. Upon completion of this lesson, you will understand how to use the upstream, location and return directives.

Upcoming Lesson: NGINX - Rewrites - An Introduction

Lesson Description:

In this lesson, we will examine basic rewrite functionality in NGINX. We will break down a few rewrite examples, and test a rewrite in real-time. When you finish this lesson, you should have a basic understanding of rewrites in NGINX and how to configure them.

Upcoming Lesson: NGINX - Load Balancing - An Introduction

Lesson Description:

In this lesson, we will examine NGINX's built-in load balancing features. We will use the upstream, location and server directives to configure and test load balancing in NGINX. When you are finsihed with this lesson, you should have a good high-level understanding of load balancing in NGINX and how to configure it.

Upcoming Lesson: Blocking Access by IP with NGINX

Lesson Description:

In this lesson, we will examine how to block IP requests using NGINX. We will take a look at the ngx_http_access_module and the associated allow and deny directives. Upon completion of this lesson, you will understand and be able to configure access restrictions in NGINX.

Upcoming Lesson: Creating SSL Certificates Using OpenSSL

Lesson Description:

In this lesson, we will learn how to create a self-signed SSL certificate using OpenSSL.

Upcoming Lesson: NGINX - Securing Virtual Hosts - HTTPS

Lesson Description:

In this lesson, we will examine how we create secure (HTTPS) virtual hosts and configure these to use SSL/TLS. We will convert an HTTP virtual host to HTTPS. When you complete this lesson, you will understand how to use SSL/TLS to secure a virtual host in NGINX.

Upcoming Lesson: Optimizing Your NGINX Configuration

Lesson Description:

In this lesson, we will examine several ways you can optimize the performance of your NGINX installation. We will test tuning and look at the results of the changes we make. Upon completion of this lesson, you will have a solid high-level understanding of how to improve the performance of NGINX via tuning. Here are the instructions for the demonstration in the lesson: Optimizing Your NGINX Configuration Install ApacheBench and perform a baseline load test We're going to become the root user.

sudo su -
Before we start tuning NGINX, we want to get a baseline measurement using ApacheBench. We will need to install apache2-utils first:
apt-get -y install apache2-utils
Now, we can perform a baseline test. We're going to use the Requests per second metric as our measure for these tests:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_processes_auto.txt ; done
Tuning worker_processes The general baseline configuration is set to auto or the number of cores in the system. Let's take a look at the number of cores in our system:
lshw -short -class cpu
The worker_processes setting is in the nginx.conf file. Open the file for editing:
vi /etc/nginx/nginx.conf
We're going to change worker_processes from auto to the number of cores on our system. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_processes_single.txt ; done
Let's change worker_processes from 1x to 2x the number of cores on our system. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_processes_double.txt ; done
Set worker_processes back to auto, save, exit and restart NGINX. Tuning worker_connections The general baseline configuration is set to 768. We want to set this to the value of ulimit -n:
ulimit -n
The worker_connections setting is in the nginx.conf file. Open the file for editing:
vi /etc/nginx/nginx.conf
We're going to change worker_connections from 768 to 1024. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_connections_auto.txt ; done
We're going to change worker_processes from auto to the number of cores on our system. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_connections_single.txt ; done
We're going to change worker_processes from 1x to 2x the number of cores on our system. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_connections_double.txt ; done
We're going to change worker_connections from 1024 to 512. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_worker_connections_512.txt ; done
Leave worker_processes at 2x and worker_connections at 512. Tuning open_file_cache and open_file_cache_valid We're going to see what effect caching some files in memory has, using the open_file_cache and open_file_cache_valid settings:
vi /etc/nginx/nginx.conf
We're going to add the following to the configuration within the http configuration:
        open_file_cache max=2048 inactive=20s;
        open_file_cache_valid 120s;
Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_open_file_cache_512.txt ; done
We're going to change worker_connections from 512 to 768. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_open_file_cache_768.txt ; done
Tuning buffer sizes Let's explore the impact of setting some buffer sizes. Add the following lines to nginx.conf:
        client_body_buffer_size 10K;
        client_header_buffer_size 1k;
        client_max_body_size 8m;
        large_client_header_buffers 4 4k;
Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_buffers.txt ; done
Tuning timeouts Let's explore the impact of setting some timeouts. Change keepalive_timeout to 15 and add the following lines to nginx.conf:
        client_body_timeout 12;
        client_header_timeout 12;
        send_timeout 10;
Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_timeouts.txt ; done
Configuring access_log buffering Let's explore the impact of enabling buffering on the access log. Edit nginx.conf and add combined buffer=16k to the end of the access_log line, right before the ; at the end of the line. Save and exit. Restart NGINX:
nginx -t
systemctl restart nginx
Now, we'll run our ApacheBench test again:
for i in `seq 1 10` ; do ab -c 1000 -n 100000 http://127.0.0.1/ | grep Requests >> test_log_buffers.txt ; done
You can check out your various test results with:
more test_*

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Configuring the NGINX Server - HTTP Virtual Hosts / Rewrites / Custom Error Pages / Directives

01:00:00

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

NGINX - Managing SSL Certificates Using OpenSSL

00:45:00

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Configuring the NGINX Server - HTTPS Virtual Hosts / Load Balancing / IP Access Restrictions

00:45:00

NGINX - Configuring and Customizing Log Files

Upcoming Lesson: NGINX - Configuring / Customizing Logging

Lesson Description:

Even though logging is configured by default in NGINX, when managing a web environment with many virtual hosts, load balancers, and more, the default logging configuration is not going to cut it. We will examine how to set logging locations, formats, verbostiy, and more. When you finish this lesson, you should have a solid understanding of how to configure your NGINX labs to you liking.

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

NGINX - Customizing Logging to Fit Your Needs

01:00:00

MariaDB - Where the Data Lives

MariaDB Basics

MariaDB - Resources and Documentation

00:04:29

Lesson Description:

In this lesson, we are going to introduce you to the https://mariadb.org, https://mariadb.com/services, and https://dev.mysql.com/doc websites. These websites are a rich resource and will assist you with installing, configuring, and maintaining your MariaDB environment. When this lesson is complete, you should have a better understanding of how these websites can be a fantastic tool for anyone working with MariaDB.

Upcoming Lesson: Configuring and Securing MariaDB

Lesson Description:

MariaDB is fast and easy to install and set up, but trading ease at the expense of security is a guaranteed way to end up in the headlines. In this lesson, we will walk through hardening a clean installation of MariaDB. We will secure the installation with the mysql_secure_installion script, configure networking, and configure Data-in-Transit and Data-at-Rest Encryption. Upon completion of this lesson, you will have a solid understanding of how to harden a fresh installation of MariaDB.

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Configuring and Securing MariaDB

01:00:00

PHP - Follow the Script

Working With PHP on the LEMP Stack

PHP - Resources and Documentation

00:01:25

Lesson Description:

In this lesson, we are going to introduce you to the php.net website. The website is a rich resource and will assist you with installing, configuring, and maintaining your PHP environment. When this lesson is complete, you should have a better understanding of how the php.net website can be a fantastic tool for anyone working with PHP and the LEMP Stack.

Upcoming Lesson: PHP - An Introduction

Lesson Description:

What is PHP and how does it work in the LEMP stack? In this lesson, we will examine how PHP is processed in the LEMP stack, and we'll break down some simple PHP code examples with a demonstration. Upon completion of the lesson, you should have a good high-level understanding of how PHP works in the LEMP stack.

Upcoming Lesson: Installing and Configuring PHP-FPM

Lesson Description:

In order to properly process PHP pages with NGINX, we need two things: PHP-FPM must be installed, configured, and running, and NGINX must be configured to send PHP pages to PHP-FPM. In this lesson, we will show you how to do both. Upon completion of this lesson, you will be able to install PHP-FPM and configure it with NGINX to properly process your PHP pages.

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Installing and Configuring PHP-FPM on Ubuntu Linux

00:30:00

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

Deploying phpMyAdmin on the LEMP Stack on Ubuntu Linux

01:00:00

Conclusion

Final Words

Upcoming Lesson: LEMP - A Review

Lesson Description:

In this lesson we will review the concepts we learned in the LEMP Stack Deep Dive course.

Upcoming Lesson: LEMP - More Resources on Linux Academy

Lesson Description:

In this lesson, we will review other Linux Academy resources that are available to you, if you would like to continue your LEMP journey.

Take this course and learn a new skill today.

Transform your learning with our all access plan.

Start 7-Day Free Trial