How to Install Nginx on Ubuntu 22.04 LTS - TechvBlogs

How to Install Nginx on Ubuntu 22.04 LTS

This article will demonstrate the method to set up an Nginx web server on Ubuntu 22.04.


Smit Pipaliya - Author - TechvBlogs
Smit Pipaliya
 

1 year ago

TechvBlogs - Google News

What is Nginx?

Nginx is a Fast, Open Source, high-performance web server that commands a huge market share in production environments. Nginx is one of the most popular web servers in the world and hosts some of the largest and highest-traffic sites on the internet. Nginx provides a content management cache, and a reverse proxy feature for HTTP and non-HTTP servers.

This article will demonstrate the method to set up an Nginx web server on Ubuntu 22.04.

1. Prerequisites

  • The operating system running Ubuntu 22.04 Linux
  • A root or non-root user with sudo privileges
  • A stable internet connection
  • Make sure Apache or any other processes are not running on port 80 or 443
  • Terminal window / Command line

2. Update Software Repositories

Updating the local package with apt command. Open a terminal window and run the following command:

sudo apt update

Upgrading the local package with apt command. Open a terminal window and run the following command:

sudo apt upgrade

3. Installing Nginx on Ubuntu 22.04 LTS

Nginx is available in the Ubuntu 22.04 default repositories. Run the following command and install Nginx:

sudo apt install nginx

Install Nginx on Ubuntu 22.04 LTS - Ubuntu - TechvBlogs

4. Verify Installation

When Nginx installed correctly, checking by the software version.

nginx -v

Install Nginx on Ubuntu 22.04 LTS - Ubuntu - TechvBlogs

5. Managing the Nginx Process

Now that you have your web server up and running, let's go over basic management commands.

To stop your web server, run this command:

sudo systemctl stop nginx 

To start your web server, run this command:

sudo systemctl start nginx

To reload your web server, run this command:

sudo systemctl reload nginx

To disable your web server, run this command:

sudo systemctl disable nginx

To enable your web server, run this command:

sudo systemctl enable nginx

To status your web server, run this command:

sudo systemctl status nginx

Install Nginx on Ubuntu 22.04 LTS - Ubuntu - TechvBlogs

6. Nginx Adjusting Firewall

Check the available ufw application profiles:

sudo ufw app list

Install Nginx on Ubuntu 22.04 LTS - Ubuntu - TechvBlogs

Let’s enable the most restrictive profile that will still allow the traffic you’ve configured, permitting traffic on port 80:

sudo ufw allow 'Nginx Full'

Install Nginx on Ubuntu 22.04 LTS - Ubuntu - TechvBlogs

Verify the change:

sudo ufw status

If you have other applications or services to allow, make sure you configure your firewall to allow traffic.

For example, using the sudo ufw allow 'OpenSSH' command will enable secure, encrypted logins over the network.

7. Test

For Verify it installed correctly Nginx, open a web browser and type in the address bar http://server_ip_address

After opening this URL, you can see the Nginx default page as in the image below:

Install Nginx on Ubuntu 22.04 LTS - Ubuntu - TechvBlogs

This article helped you install Nginx on Ubuntu using a set of simple commands.

Thank you for reading this blog.

Read Also: How To Install PHP 8.2 on Ubuntu 22.04

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

If you have any queries or doubts about this topic please feel free to contact us. We will try to reach you.

Comments (0)

Comment


Note: All Input Fields are required.