To run NGINX in debug mode you need to run the nginx-debug binary (/usr/sbin/nginx-debug) instead of the normal nginx binary (/usr/sbin/nginx), as described in the NGINX docs (Here). It is not possible to run NGINX in debug mode by setting the error_log to debug level.
To run the nginx-debug binary, you can start the nginx-debug service, which simply is the daemonized version of the nginx-debug binary:
systemctl cat nginx-debug.service | grep -i execstart
ExecStart=/usr/sbin/nginx-debug -c /etc/nginx/nginx.conf
Here is how you can start the nginx-debug service:
1- First you need to stop the normal NGINX service:
systemctl stop nginx.service
2- Confirm that the service is indeed stopped:
systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sat 2021-03-27 12:36:27 CDT; 3s ago
Docs: http://nginx.org/en/docs/
Process: 2244375 ExecStopPost=/bin/sh -c ps -C nginx -o pid,command= --no-headers | grep "nginx: logger process" | awk "{ print \$1 }" | xargs -r kill -9; ps -C splitlogs>
Process: 2244372 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 2201796 ExecReload=/bin/sh -c /bin/kill -s HUP $MAINPID; ps -C nginx -o pid,command= --no-headers | grep "nginx: logger process" | awk "{ print \$1 }" | xargs -r>
Process: 2244335 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 2244350 (code=exited, status=0/SUCCESS)
3- Start the nginx-debug service:
systemctl start nginx-debug.service
4- Confirm that the nginx-debug service is running:
systemctl status nginx-debug.service
● nginx-debug.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx-debug.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2021-03-27 12:36:47 CDT; 4s ago
Docs: http://nginx.org/en/docs/
Process: 2244406 ExecStart=/usr/sbin/nginx-debug -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 2244423 (nginx-debug)
Tasks: 24 (limit: 11432)
Memory: 14.0M
CGroup: /system.slice/nginx-debug.service
├─2244407 Passenger watchdog
├─2244410 Passenger core
├─2244422 nginx: logger process
├─2244423 nginx: master process /usr/sbin/nginx-debug -c /etc/nginx/nginx.conf
├─2244428 /usr/local/cpanel/bin/splitlogs --dir=/var/log/nginx/domains --main=server.test-004.net --suffix=-bytes_log
├─2244429 /usr/local/cpanel/bin/splitlogs --dir=/var/log/nginx/domains --main=server.test-004.net --mainout=/var/log/nginx/access.log
├─2244431 nginx: worker process
├─2244432 nginx: cache manager process
└─2244433 nginx: cache loader process