[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
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 Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

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

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

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM