This Nginx tutorial 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, and as a reverse proxy for Apache and other web 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, and as a reverse proxy for Apache and other web servers.
If you are a developer or system administrator, the chances are that you're dealing with Nginx on a regular basis. Starting, stopping, and restarting/reloading are the most common tasks when working with an Nginx webserver.
In this guide, we'll explain how to start, stop, and restart Nginx on Linux 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.
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 the following command:
sudo systemctl start nginx
Execute the following command to stop the Nginx service:
sudo systemctl stop nginx
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
In this guide, we have shown you how to start, stop, and restart the Nginx web server on Linux systems.
If you have any questions or feedback, feel free to comment below.
Looking to develop real-time applications? **[Hire Dedicated Linux Developer](https://hourlydeveloper.io/hire-dedicated-linux-developer/ "Hire Dedicated Linux Developer")** from **[HourlyDeveloper.io](https://hourlydeveloper.io/...
User Administration in Linux - Linux Tutorial - Linux Training
Package Management in Linux - Linux Tutorial - Linux Training
Nginx is an open-source, high-performance HTTP and reverse proxy server that powers some of the largest sites on the Internet. Compared to Apache, Nginx can handle a much large number of concurrent connections and has a smaller memory footprint per connection.
In this guide, you’ll install a Linux, Nginx, MySQL, PHP (LEMP) stack on a CentOS 8 server. This guide will walk through the process of setting up a LEMP stack with MariaDB as the database management system. Built a flexible foundation for serving PHP websites and applications to your visitors, using Nginx as web server. Set up Nginx to handle PHP requests through `php-fpm`, and you also set up a MariaDB database to store your website’s data.