Methods of payment Abuse

How do I enable Nginx debugging mode?

18.10.2023, 23:39

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.

What is debugging mode?

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:

error_log /var/log/nginx/error.log debug;

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.

How do I turn on the mode?

First of all, you need to install the Nginx version with debugging support. To check if your current version supports this mode, type:

nginx -V

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:

sudo yum install nginx-debug

Now there is another executable file, and it is already built with debugging support:

nginx-debug -V

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:

error_log /var/log/nginx/domains/test.pq.hosting.error.log debug

Install the regular version and run the debug version:

systemctl stop nginx

systemctl start nginx-debug

That's all