How to install NGINX on Debian 11

NGINX is a web server and its use is extended to HTTP cache, mail proxy, reverse proxy, and load balancer. The term HTTP cache (also known as Web cache) refers to a system that is used to optimize World Wide Web (WWW). Load Balancing as its name refers; it is a process that distributes multiple tasks to multiple computing machines. Whereas reverse proxy retrieves data from several sources and returns those resources to client; additionally, proxy server primarily balances the load.

NGINX started as a project in 2002 by a Russian engineer and was available publicly in 2004. After that public release, NGINX emerged as a best tool for caching, web serving, reverse proxying. And as the time passed, millions of websites started deploying NGINX for better performance and scalability. Companies like Facebook, Microsoft, IBM, Google, Adobe, LinkedIn are using NGINX.

In this descriptive post, we will guide you to install NGINX on your Debian 11 system and you can also get basic workflow of NGINX.

Let’s start with the aim to understand the working of NGINX:

How NGINX works

How to install Kali Linux in Window...

The building block of NGINX focuses to provide a high concurrency output by using low memory and it follows master and slave/worker phenomena to perform tasks: For instance, Master process reads the configuration settings and binds it to ports; after binding, master process creates several worker/slave processes. After creating worker processes, now all the operations are managed by workers. In between worker process and master process there are two other process named as cache loader and cache manager. Cache loader is only supposed to load cache (disk-based) into memory and this process exits after loading cache; thus, it uses less resources. Whereas cache manager keeps the entries of disk cache in a configured and ordered sizes.

How to install NGINX on Debian 11

This section describes the ways to install NGINX on your Debian 11 system: you can do so by following any of the given methods:

  • Method 1: using Debian 11 repository
  • Method 2: using NGINX official repository

The upcoming sections illustrate the steps carried out in both methods:

Method 1: How to install NGINX on Debian 11 using default repository

This method will guide you to install NGINX from Debian 11 repository:

Step 1: Update the packages on Debian 11

The first and recommended step is to update the list of packages on your Debian 11:

$ sudo apt update

Step 2: Install NGINX

Once the packages list is updated; you can install NGINX with the help of below-mentioned command:

$ sudo apt install nginx

Step 3: Verify the installation

Check the installed version of NGINX with the help of following command:

$ sudo nginx -v

Moreover, you can check the NGINX server is running; for this you can follow the command mentioned below:

$ curl -I

Method 2: How to install NGINX on Debian 11 from official NGINX repository

With the help of this method, you can install latest version of NGINX, Following are the steps that must be carried out to do so:

Step 1: Add NGINX signing key

Download the key for signing NGINX by using the command below:

$ sudo wget 

And to add the downloaded key to program key ring of apt by using the below mentioned command:

$ sudo apt-key add nginx_signing.key

Step 2: Edit the sources.list file

Firstly, access the sources.list file with any editor you like; the following command will open the file using nano editor:

$ sudo nano /etc/apt/sources.list

Now add the following lines in source.list file to get NGINX on Debian 11 (Bullseye):

Note: If you want to get NGINX for other Debian releases, you can replace code name of that release with “bullseye” in the below lines:

deb bullseye nginx
deb-src bullseye nginx

Press “Ctrl+S” to save and “Ctrl+X” to get out of editor:

Step 3: Install NGINX

Update the packages list by using the below mentioned command:

$ sudo apt update

And install NGINX by issuing the command stated below:

$ sudo apt install nginx

How to remove NGINX from Debian 11

Before executing the remove command, you must ensure to empty the “/var/www/html” directory by issuing the command:

$ sudo rm -rf /var/www/html

Now you can remove NGINX and all its dependencies by using the command mentioned below:

$ sudo apt purge nginx nginx-common


NGINX is a well-known web server with open-source access and is used by top rated companies because of its extensive support for HTTP cache, reverse proxying, load balancer etc., We have provided a guide that contains two methods to install NGINX on Debian 11: In Method 1, NGINX is installed using the default repository of Debian 11; it is noticed that you may encounter old packages when using Method 1. In this case, the second method can be followed to get the latest version of NGINX from official repository of NGINX.