How to Install Nginx on Ubuntu 22.04

Nginx is a powerful and efficient web server. In this guide, you’ll learn how to install Nginx on Ubuntu 22.04, a step crucial for hosting websites or web applications.

Updating System Packages

First, update your system’s packages:

sudo apt update && sudo apt upgrade -y

Installing Nginx

Install Nginx using the following command:

sudo apt install nginx

Starting and Enabling Nginx

Once installed, start and enable Nginx to run on boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Verifying Nginx Installation

To confirm that Nginx is running:

sudo systemctl status nginx

Configuring Firewall

Configure the UFW firewall to allow HTTP and HTTPS traffic:

sudo ufw allow 'Nginx Full'

Accessing Nginx

To access the Nginx landing page, go to your web browser and enter your server’s IP address.

Managing Nginx Service

Here are common commands to manage the Nginx service:

1. Restart Nginx:

sudo systemctl restart nginx

2. Reload Nginx (for configuration changes):

sudo systemctl reload nginx

3. Stop Nginx:

sudo systemctl stop nginx

You’ve successfully installed Nginx on Ubuntu 22.04. This basic setup is suitable for hosting static websites. For more complex configurations, such as setting up server blocks (similar to virtual hosts in Apache), SSL certificates, and reverse proxy settings, additional configuration is required.

About the author

Technical Sahil

Hello I’m Sahil, May be most of you guys know me as Technical Sahil on YouTube. Founder of Hostrigger & Mailracle and running several other things online.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *