Nginx Complete Guide and Cheatsheet

Learn Nginx from the ground up with this complete guide and cheatsheet. From installing the latest version to configuration, security, and performance optimization.

 •  5 min read  • 
0views
Featured image for Nginx Complete Guide and Cheatsheet

Nginx (engine-x) is a powerful web server and reverse proxy widely used for high-performance web applications. In this guide, you’ll find a complete guide to help you configure, optimize, and secure Nginx for your projects.

Installing Nginx

Let’s start by installing Nginx on your server or local machine. The installation steps can vary depending on your operating system. In this guide, I’ll cover the process for Ubuntu and Debian-based systems. If you’re using another OS, you can follow the instructions in the official Nginx documentation.

By default, in Ubuntu/Debian, the Nginx version available in the package manager might not be the latest. To install the latest stable version, you can add the official Nginx repository.

Let's first update the package list and install prerequisites:

sudo apt update
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring

Next, add the Nginx signing key:

curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg

Then, add the Nginx repository to your sources list:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list

Now, update the package list again and install Nginx:

sudo apt update
sudo apt install nginx

You can verify the installation by checking the Nginx version:

nginx -v

This should display the installed Nginx version like this:

nginx version: nginx/1.24.0

To check if Nginx all modules are installed, you can run:

nginx -V

Join the Discussion

Your email will not be published or shared
Be respectful and constructive in your comments

Be the first to share your thoughts!