Nginx is a high performance open source web server. It is a very popular software designed to process HTTP requests from clients (such as web browsers) and serve them web pages and other content. Installing Nginx is very simple and is based on only one command. Enter the following command to easily install this web server:

apt install nginx

You must agree to the installation by pressing Y. The output will be something like this.

This article uses Debian 12 and runs all commands as root. You always get this access when you purchase virtual or dedicated servers from AlexHost.

Launch Nginx

Starting Nginx is quite simple. Just run the following command:

systemctl start nginx

If successful, the command does not produce any results.

If you are using a Linux distribution without systemd to run Nginx type:

service start nginx

Instead of manually starting the Nginx service, it is recommended to configure it to start at system boot:

systemctl enable nginx

Restart Nginx

The reboot process is quick, easy to learn, but very important. Every time you make any changes in Nginx, you need to restart Nginx every time. The reboot option will load the new configuration, start new worker processes with the new configuration, and gracefully shut down old worker processes.

To restart Nginx, use one of the following commands:

systemctl reload nginx
service reload nginx

Testing Nginx configuration

Whenever you make changes to the Nginx server configuration file, it is recommended to check the configuration before restarting or reloading the service.

Use the following command to check your Nginx configuration for any syntax or system errors:

sudo nginx -t

The output will look something like this.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful