How to Install Nginx on Ubuntu 22.04
In this guide, we will walk you through how to install Nginx on Ubuntu 22.04, enabling you to set up a powerful web server for your applications and websites.
Nginx is an open-source web server that serves as a reverse proxy, load balancer, and HTTP cache. It's known for its high performance: stability, rich feature sets, and low resource consumption.
This article explains how to install the Nginx web server on Ubuntu 22.04.
Prerequisites
Launch the Ubuntu 22.04 instance on Neevcloud
Create a new Domain or subdomain A record that points to your server IP address.
Access the server using SSH
Let's follow step by step for a complete Nginx installation and basic configuration on Ubuntu 22.04.
Update && Upgrade the system
First, ensure your package list is up to date to avoid any issues with outdated packages
sudo apt-get update -y
sudo apt-get upgrade -y

Install Nginx
Use the apt command to install the nginx service.
sudo apt-get install nginx -y

Start and Enable Nginx
Once the Nginx is installed, start the Nginx service
sudo systemctl start nginx
Enable it to start when the system rebooted
sudo systemctl enable nginx

Check the Status
Ensure Nginx is running smoothly.
sudo systemctl status nginx

Check nginx default port
To verify that Nginx is running on its default port (80), execute the command below
sudo ss -antpl | grep nginx

Adjusting The Firewall
To configure ufw
to allow Nginx connections, it's important to find a balance between security and traffic requirements. You must allow HTTP traffic if your server isn't set up with SSL. To do this, enable connections on the port
sudo ufw allow 'Nginx HTTP'
sudo ufw enable
sudo ufw status

Test Nginx
To verify your Nginx installation, navigate to http://your-server-ip
your web browser. If the installation is successful, you will be greeted by the Nginx test page.
You should see the default Nginx welcome page.

Last updated