[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedMarch 6, 2023

How to Start, Stop, or Restart Nginx

How To Start, Stop, Or Restart Nginx

This guide explains how to start, stop, and restart Nginx on Linux servers.

Nginx pronounced “engine x” is a free, open-source, high-performance HTTP and reverse proxy server responsible for handling the load of some of the largest sites on the Internet. It can be used as a standalone web server or as a reverse proxy for Apache and other web servers.

The instructions assume that you are logged in as root or user with sudo privileges.

Most of the current Linux distributions are using SystemD as the default init system and service manager. Older distributions are based on SysVinit and using init scripts to manage services.

Both SystemD service units and SysVinit script takes the following arguments to manage the Nginx service:

  • start: Starts the Nginx service.

  • stop: Terminates the Nginx service.

  • restart: Stops and then starts the Nginx service.

  • reload: Gracefully restarts the Nginx service. On reload, the main Nginx process shuts down the child processes, loads the new configuration, and starts new child processes.

  • status: Shows the service status.

The commands for managing the Nginx service are the same on all Linux distributions.

 

Start, Stop and Restart Nginx using systemctl

SystemD is a system and service manager for the latest Ubuntu 18.04 /16.04 , CentOS 7 /8 , and Debian 10 /9 releases.

Whenever you make changes to the Nginx configuration, you need to restart or reload the webserver processes. Execute the following command to restart the Nginx service:

sudo systemctl restart nginx

When adding or editing server blocks, prefer reloading over restarting. Restart the service only when making significant modifications like changing ports or interfaces. On reload, Nginx loads the new configuration, starts new worker processes with the new configuration, and gracefully shuts down old worker processes.

Run the command below to reload the Nginx service:

sudo systemctl restart nginx

Nginx can also be directly controlled with signals . For example, to reload the service, you can use the following command:

sudo /usr/sbin/nginx -s reload

To start the Nginx service, execute:

sudo systemctl start nginx

Execute the following command to stop the Nginx service:

sudo systemctl stop nginx

 

Start, Stop and Restart Nginx using SysVinit

Older (EOLed) versions of Ubuntu, CentOS, and Debian are using init.d scripts to start, stop and restart the Nginx daemon.

Restart the Nginx service:

sudo service nginx restart

Start the Nginx service:

sudo service nginx start

Stop the Nginx service:

sudo service nginx stop

 

Conclusion

We have shown you how to start, stop, and restart the Nginx web server on Linux systems.

Keep reading
How to understand TCP/IP protocol.
April 11, 2023

How to understand TCP/IP protocol.

What is TCP? Transmission Control Protocol (TCP) is a communications standard that enables application programs and computing devices to exchange messages over a network. It is designed to send packets across the internet and ensure the successful delivery of data and messages over networks. TCP…

Read article
How to use Locate Command.
April 11, 2023

How to use Locate Command.

How To Use Locate Command. In this article, we will explain how to use the locate command. One of the most common operations when working on Linux is to search for files and directories. There are several commands on Linux systems that allow you to search for files, with find and locate being the…

Read article
how to use cp command.
April 11, 2023

how to use cp command.

How To Use Cp Command. In this article, we will explain how to use the cp command. When working on Linux and Unix systems, copying files and directories is one of the most common tasks you’ll perform on a daily basis. cp is a command-line utility for copying files and directories on Unix and Linux…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00