Sep 17, 2019 9:00 AM

Installing Nginx on Debian/Ubuntu

In this article I will explain how to install an Nginx server on a Debian/Ubuntu operating system.

This instruction was executed on operating systems: Debian 10, Debian 9, Ubuntu 20.10, Ubuntu 20.04, Ubuntu 19.10.

Installing Nginx server

Before any software installation, it is recommended to update the list of repository packages by running the command in the terminal:

sudo apt-get update

Install the Nginx server by running the command in the terminal:

sudo apt-get install nginx

Nginx installation command

Checking Nginx status

Let's check if Nginx is enabled to start automatically when the system is booted by running the command in the terminal (expected result "enabled"):

sudo systemctl is-enabled nginx

Let's check if Nginx is active at the moment by running the command in the terminal (expected result "active"):

sudo systemctl is-active nginx

We can also check the Nginx status with additional information about the service by running the command in the terminal:

sudo systemctl status nginx

–°hecking Nginx status

If the Nginx server is not installed, an error will be displayed when checking the status:

Error checking Nginx status

Testing Nginx access

Let's make sure that the Nginx server is working by entering the IP address of your server in the browser:

http://192.168.0.101

or for localhost

http://localhost

If all is well, you will see the Nginx welcome page:

Nginx welcome page

Nginx process management

To manage the server, you may need the following commands.

Start Nginx

Start the Nginx server by running the command in the terminal:

sudo service nginx start

Stop Nginx

Stop the Nginx server by running the command in the terminal:

sudo service nginx stop

Restart Nginx

Restart the Nginx server by running the command in the terminal:

sudo service nginx restart

Verifying Nginx configuration

Before restarting the Nginx server, you need to check the configuration for validity by running the command in the terminal:

sudo nginx -t

Reloading Nginx configuration

We can apply configuration changes without losing connections by running the command in the terminal:

sudo service nginx reload

Other articles