How to install Nginx on Ubuntu 22.04

Estimated reading: 2 minutes 805 views

NGINX is an open-source high performing web server. NGINX is well known for its performance and effective results as compared to Apache or other web servers. NGINX serves multiple purposes such as email proxy server, reverse and forward proxy serving, media streaming, load balancing, and so on.

NGINX acts as a forward proxy server for email protocols (IMAP, SMTP, and POP3). Moreover, NGINX provides reverse proxy server and load balancing support for well-known computer protocols such as HTTP, TCP, and UDP servers.

NGINX is available for various Linux systems such as Debian, CentOS, RedHat Enterprise Linux (REHL), and more. This writeup acts as an installation guide of NGINX on Ubuntu 22.04.

1. Install NGINX on Ubuntu 22.04

Since Nginx is available in the Ubuntu repositories, you can directly install Nginx using the aptpackage management and installation system.

Step 1: Update the system’s packages by issuing the following command:

# apt update

Step 2: Once the system’s packages are updated, you can install NGINX with the help of the following command:

# apt install nginx -y

Step 3: Verify the installation by checking version of NGINX:

# nginx -v

Out put:

 nginx version: nginx/1.18.0 (Ubuntu)

Allow Nginx to start on system:

 # systemctl enable nginx

Start and check the status of the Nginx service:

 # systemctl start nginx
# systemctl status nginx

 

Step 4: Now, you need to configure the firewall to allow traffic on HTTP port 80 and HTTP port 443. You can use the following command to get the traffic on both ports for NGINX:

# ufw allow 'Nginx full'
# ufw reload

Please note:  If an error occurs” sudo: ufw: command not found ”  .you can fix the error by running the following command to install ufw then try again:  apt install ufw

You can enable ufw by typing  the following command :  ufw enable

Output will have the following:

Step 5 : Check the website

 

http://IP_address

You will be redirected to the default Nginx web page:

When you show this, it is successfully installed and nginx is ready to be managed.

How to remove NGINX from Ubuntu 22.04

NGINX server can be removed from Ubuntu 22.04 with the help of the following command. This command removes the NGINX server alongside its dependencies from Ubuntu 22.04:

# apt autoremove nginx --purge

Conclude

Nginx with many extended features can be a great application for your system. In this tutorial, I have shown you how to install Nginx for Ubuntu 22.04

Leave a Comment

Share this Doc

How to install Nginx on Ubuntu 22.04

Or copy link

CONTENTS