We have already mentioned that users often encounter an error such as not found Nginx. So, it is often necessary to activate the so-called debugging mode to eliminate it. In this article, we will talk about what it is and how this operation is performed.
Nginx Debugging mode is a special Nginx mode of operation that allows developers to track and fix errors during the processing of requests by the server. In debugging mode, Nginx outputs additional information about each request, as well as logs various events and server actions. This allows you to analyze the server operation at a deeper level and quickly detect and fix problems.
To enable it, you must specify the appropriate option in the server configuration file, for example:
After enabling, you can analyze the server logs and find the cause of the errors. This can be useful when debugging unexpected server behavior, optimizing performance, or developing new features.
First of all, you need to install the Nginx version with debugging support. To check if your current version supports this mode, type:
The output should contain the line "--with-debug". If the line is missing, debugging is not supported, then you should install the supported version. In CentOS, such a package is called nginx-debug. To install it, type:
Now there is another executable file, and it is already built with debugging support:
Open the configuration file of your site or the global configuration file, if you did not set the log settings separately for each site, and at the end of the error_log drain, replace error with debug:
Install the regular version and run the debug version:
systemctl stop nginx
systemctl start nginx-debug
That's all