Nginx Installation

Nginx Installation

Introduction

This guide will walk you through the steps to install and setup Nginx on Ubuntu 22.04.

What is Nginx?

Nginx is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

Prerequisites

  • A server running Ubuntu 22.04
  • A non-root user with sudo privileges

Installation

Step 1 - Install Nginx

sudo apt update
sudo apt install nginx

Step 2 - Adjust the Firewall

sudo ufw app list

You should see a list of application profiles:

Output
Available applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH

Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)

sudo ufw allow 'Nginx Full'

Step 3 - Check your Web Server

systemctl status nginx
Output
...
Active: active (running) since Mon 2018-01-14 14:19:13 UTC; 1 day 17h ago
...

Step 4 - Manage the Nginx Process

sudo systemctl stop nginx
sudo systemctl start nginx
 
sudo systemctl restart nginx
sudo systemctl reload nginx
 
sudo systemctl disable nginx
sudo systemctl enable nginx

Step 5 - Reload Nginx Configuration

sudo nginx -s reload

Step 6 - Check Nginx Configuration Syntax

sudo nginx -t

Conclusion

You have successfully installed Nginx on your Ubuntu 22.04 server. You can now start deploying your applications and use Nginx as a web or proxy server.

Resources

What's Next

Nginx Configuration

Learn how to configure Nginx on Ubuntu 22.04

View