Programster's Blog

Tutorials focusing on Linux, programming, and open-source

NGINX CLI Cheatsheet

This cheatsheet is just for the commands you can run for Nginx and is nothing to do with the configuration files.

Test The Configuration

If you make a change to your configuration and want to check that everything is okay before having the changes take effect, then use this command.

sudo nginx -t

Reload the Configs

The safest way to apply a configuration change when your nginx server is already running. If you messed up your config, the server will just keep running wit the original configuration. Refer here.

sudo nginx -s reload

Restart The Service

sudo service nginx restart

If your configs are invalid/malformed, this will result in your webserver stopping and not starting. It is safer to use the reload command above if you are just making a configuration change.

Graceful Shutdown

This will cause nginx to stop accepting new requests and finish serving any that are currently processing before stopping.

nginx -s quit

Fast Shutdown

This will terminate nginx, even in the middle of handling a request.

nginx -s stop


Last updated: 17th July 2023
First published: 16th August 2018