Gracefully Restart Nginx Web Server After Changes Made In a Config File

http‮:s‬//www.lautturi.com
Gracefully Restart Nginx Web Server After Changes Made In a Config File

To gracefully restart the Nginx web server after making changes to a configuration file, follow these steps:

  1. Open a terminal and log in as the root user or use sudo to execute the commands.

  2. Check the syntax of the Nginx configuration file by running the following command:

nginx -t

This will check the syntax of the configuration file and display any errors or warnings.

  1. If the syntax is correct, send a signal to the Nginx master process to reload the configuration by running the following command:
nginx -s reload

This will gracefully reload the configuration file, allowing existing connections to complete while new connections will be handled with the new configuration.

  1. Verify that the Nginx server is running by running the following command:
systemctl status nginx

This will display the status of the Nginx service. The output should show that the service is active and running.

Note: If you made changes to the Nginx configuration file that caused the server to fail to start, you may need to use the nginx -s stop command to stop the Nginx server and then start it again using the systemctl start nginx command.

Created Time:2017-10-28 20:40:39  Author:lautturi