How to Install NGINX on Ubuntu 22.04

NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability.

In this tutorial, i am going to show you how to install, uninstall and configure NGINX on Linux ubuntu 22.04 system using command line.

How to Install NGINX on Ubuntu 22.04

Follow the below given instruction to install and configure NGINX on linux ubuntu 22.04 using command line:

  • Step 1 – Open Terminal OR Command Line
  • Step 2 – Update APT Packages
  • Step 3 – Download and Install NGINX
  • Step 4 – Verify NGINX Installation on Ubuntu 22.04
  • Step 5 – Configure Firewall For NGINX
  • Step 6 – Test Installation in Browser
  • Step 7 – Configure NGINX Server

Step 1 – Open Terminal OR Command Line

First of all, Open the terminal application by pressing Ctrl+Alt+T.

Step 2 – Update APT Packages

Then update apt packages by running the following command on command line:

Step 3 – Download and Install NGINX

To run the following command on command line or terminal to download and install NGINX on linux ubuntu 22.04 system:

sudo apt install NGINX

Step 4 – Verify NGINX Installation on Ubuntu 22.04

Once the installation of NGINX on linux ubuntu system has been done; then execute the following command on command line to verify NGINX installation:

sudo systemctl status NGINX

Step 5 – Configure Firewall For NGINX

NGINX server from various HTTP and non-HTTP web servers on port 443, 80, or both of these ports. So use the following commands to configure firewall for NGINX for linux ubuntu system:

sudo ufw allow ‘NGINX Full’

Step 6 – Test Installation in Browser

Then open web browser and hit the following url with ip address to test NGINX installation:

http://YOUR_IP

Step 7 – Configure NGINX Server

Configure NGINX server for it to restart after system reboots:

sudo systemctl enable NGINX

And use the following additional commands to check the status of the NGINX server, in addition to restarting it, reloading it, starting it, stopping it, and disabling it from starting every time the system boots up.

For NGINX Status

sudo systemctl status NGINX

For Restart NGINX

sudo systemctl restart NGINX

For Reload NGINX

sudo systemctl reload NGINX

For Start NGINX

sudo systemctl start NGINX

For Stop NGINX

sudo systemctl stop NGINX

For Disable NGINX

sudo systemctl disable NGINX

Uninstalling NGINX Server

Run the following commands to uninstall NGINX Server from linux ubuntu system:

sudo apt-get purge NGINX
sudo apt-get autoremove

Conclusion

In this tutorial, i have shown to you how to install, uninstall and configure NGINX on Linux ubuntu 22.04 system using command line.

More Tutorials

Leave a Comment