Before (re)starting nginx
, the configuration files should be tested:
service nginx configtest
(The test will also be performed when loading or starting nginx
, but it is good practice to check it manually.)
To check the configuration files using nginx
itself:
/usr/sbin/nginx -t
The output should look something like this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Important: nginx
does only check if the config file is valid. It does not, for example, check if the PHP-FPM ports or sockets are working.
Remember that /etc/nginx/nginx.conf
has a reference to include the configuration files for each enabled website (/etc/nginx/sites-enabled/*
). If an error is found in one of these files, it will show in the output.