Methods of payment Abuse

How to enable Nginx debugging mode?

18.10.2023, 23:39

We have already told you that users often encounter such an error as not found Nginx. So, it is often necessary to activate the so-called debugging mode to eliminate this error. In this article we will tell you what it is and how this operation is performed.

What is debug mode?

Nginx debug mode is a special mode of Nginx operation that allows developers to monitor and fix errors in the process of processing requests by the server. In debug mode, Nginx displays additional information about each request and logs various events and actions of the server. This allows you to analyze server operation on a deeper level and quickly detect and fix problems.

To enable it, you need to specify the corresponding option in the server configuration file, for example:

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

Once enabled, you can analyze the server logs and find the cause of errors. This can be useful when debugging unexpected server behavior, optimizing performance or developing new features.

How to enable the mode?

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

nginx -V

режим отладки Nginx

The output should contain the line"--with-debug". If the line is missing, debugging is not supported, then you should install a version with support. In CentOS, this package is called nginx-debug. To install it, type:

sudo yum install nginx-debug

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

nginx-debug -V

Open your site's configuration file or global configuration file if you didn't set 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

режим отладки Nginx

Install the regular version and run the debug version:

systemctl stop nginx
systemctl start nginx-debug

That's it.