Restart Nginx on Ubuntu 22.04

Nginx is a web server and it is also used as an HTTP cache. It is said to be a high-performance HTTP because of its effectiveness and speed. This server is also used for other servers. For instance, it is said to be a standalone service that assists the Apache server. The Nginx server also acts as a proxy server for the mail. The composition of this server mainly consists of the C programming language. The operating systems that is compatible with this server include Microsoft Windows, macOS, and Linux.

This article will explain the restart approach of the Nginx server once it is installed completely. So first we will explain the installation process of the server with its process of enabling and restarting.

Update the Packages Through the Sudo Command

The very first step in the installation of the Nginx server is to open the console Ubuntu terminal to apply commands to it, using the short key Ctrl+Alt+t. Whenever we want to install any application on Ubuntu you need to first update the existing packages to prepare the operating system so that a new application can be installed on it. This will demand a password to verify the user.

$ Sudo apt update

Sometimes only an update command is required before you proceed with the installation. Whereas in other cases, you need to first add further repositories that are essential for the installation. In this case, only the Update command will be enough to upgrade all the existing packages.

Install Nginx to the System

After the updating process, we will install the Nginx server on the system. This will be done through a simple command followed by ‘Sudo’. All the packages and their dependencies will be checked. Furthermore, the packages that will be added in this process are also listed so that the user must have the know-how of the composition and functionality of the server.

During the installation, the system asks the user if he wants to continue the process of installation or wants to quit. So we will select ‘Y’ for sure to proceed further.

Check Nginx Version

Once you are ready with the installation procedure, you can check the version of the server. By doing this, the user will be able to know whether this version of Nginx is compatible with the operating system or not.

$ Nginx -v

Nginx Verification of Installation

Installation of the server is just one step. To get the server in a working state, you need to go through some further steps. By verifying the status of the server, we will check if the server is running or not.

$ sudo systemctl status Nginx

By default, if the installation is completed smoothly without encountering any errors, the server is in an active state. Further information that is displayed with the running status is that the server has the specified process ID. Allocated memory is also displayed.

After the confirmation of the server status, we will enable the Nginx server to prepare the functionalities before we start it to work.

$ sudo systemctl enable Nginx

By using the enable command, the system will display that this server is now enabled.

The server setup is now in a position to start it, so we will use the start and restart commands together to work on this server.

Firewall Configuration

The main step in enabling the server is the configuration of the firewall once the server has started. We will do configuration regarding two ports: HTTP port 80 and HTTP port 443. The configuration will allow traffic on both these ports. For Nginx, we will use a command to have traffic on both these ports.

$ sudo ufw allow 'Nginx full'

After that, we will again load the firewall through a reload command.

$ sudo ufw reload

Installation and Configuration Test After the Restart

There are two methods to check the working of the Nginx server on Ubuntu. One is to check from a graphical user interface via the browser.

After the successful configuration, we can check the working status of Nginx in the browser. The address is mentioned here:

https: //

Launch any web browser. In the address bar, use the above-mentioned address to see the functionality of the server.

You will see that a webpage is opened that ensures the working of Nginx.

On the other hand, we can also test in another way by getting the resultant value through a command written on the terminal.

$ curl –I

‘curl’ is just like sudo, which assists the user to update or download anything on Ubuntu. You can see that the server name is written on the second line, which shows the name of Nginx on the operating system. The further details contain the content type that is HTML. The whole web page composition is also mentioned.

Stop Working on Nginx

Like restart, we can also stop the server from working.

$ sudo systemctl stop Nginx

Once you have stopped the server, you can again restart it until it is enabled. The server can also become disabled through a command.

$ sudo systemctl disable Nginx

Uninstall Nginx

To completely remove the Nginx server from the system, we will use an auto-remove command along with ‘purge’. This will first read all the packages and dependencies that the server had after the installation and also show the list of packages that will be removed.


NGINX is a web server. It is installed directly by using a couple of commands. As all the packages are already present in the repositories, you just need to update them. We have explained all the processes of installation and restarting the server by using the browser and through the terminal as well. The step-by-step sequence of commands helps the user to see the status of the installed server once it is started. This article also contains the command to disable the working of the server.


Similar Posts