How to dismiss nginx warning message nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)

I'm running nginx using common user not root. I have nginx installed system-wide, but have nginx.conf in HOME.

$HOME/nginx/nginx.conf

worker_processes  1;
error_log  /home/worker/nginx/log/nginx/error.log warn;
pid        /home/worker/nginx/run/nginx.pid;
events {
  worker_connections  1024;
}
http {
  include      /etc/nginx/mime.types;
  default_type application/octet-stream;
  access_log   /home/worker/nginx/log/nginx/access.log;
  server {
    listen 8080;
    root /home/worker/nginx/data;
  }
}

start nginx

$ nginx -c /home/worker/nginx/nginx.conf
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)

As you can see in the nginx.conf, I have defined error_log, but I still got the warning message:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)

nginx itself works, just want to remove this warning message, how can I do that?


Recently (2020-11-19), an -e option was added to nginx, allowing you to override the error log path that has been compiled in. You can use that option to point nginx to a user-writeable file (or maybe stderr).

See https://trac.nginx.org/nginx/changeset/f18db38a9826a9239feea43c95515bac4e343c59/nginx


There doesn't seem to be a way to eliminate this "alert".

See same question in StackOverflow: https://stackoverflow.com/questions/34258894/nginx-still-try-to-open-default-error-log-file-even-though-i-set-nginx-config-fi