How to test your NGINX configuration

Description

Ensuring you have a proper NGINX configuration is important in determining web servers errors. Both Apache and NGINX are designed to bypass minor errors in the configuration files if it doesn’t lead to a fatal error. That’s basically the different between a reload and a restart command. Generally speaking we always recommend doing a reload as this will reload the configurations that are valid. You might find yourself in a situation where reload works but some sites don’t load due to a configuration error.

How to ensure your NGINX configuration is valid

Run the following command to test your NGINX configuration without disrupting the service at all:

nginx -t

-t tests the configuration file and will show in which file and on which line number there might be a problem.

You can also run the same command but with a capital ‘T’:

nginx -T

-T is the same as -t but also dumps configuration files to standard output

Reference

man nginx

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top