access_log and error_log ownership

G
  • 11 Mar '12
Hello,

I noticed the following behavior.

1) stop nginx (/etc/init.d/nginx stop on a debian box)
2) remove all logs in /var/log/nginx/
3) start nginx

now /var/log/nginx/access.log and /var/log/nginx/error.log are owned by
root:root.

in fact it's the same for all other vhosts log files.

4) issue kill -USR1 `cat /var/run/nginx.pid`

now /var/log/nginx/access.log and /var/log/nginx/error.log are owned by
www-data:root, where www-data is nginx's user as per /etc/nginx/nginx.conf
configuration file.

same for all vhosts log files.

Why is it so?

Gregory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120311/a83ad235/attachment.html>
M
  • 11 Mar '12
Hello!

On Sun, Mar 11, 2012 at 05:18:39PM +0100, Gr?gory Pakosz wrote:

> Hello,
> 
> I noticed the following behavior.
> 
> 1) stop nginx (/etc/init.d/nginx stop on a debian box)
> 2) remove all logs in /var/log/nginx/
> 3) start nginx
> 
> now /var/log/nginx/access.log and /var/log/nginx/error.log are owned by
> root:root.
> 
> in fact it's the same for all other vhosts log files.
> 
> 4) issue kill -USR1 `cat /var/run/nginx.pid`
> 
> now /var/log/nginx/access.log and /var/log/nginx/error.log are owned by
> www-data:root, where www-data is nginx's user as per /etc/nginx/nginx.conf
> configuration file.
> 
> same for all vhosts log files.
> 
> Why is it so?

When reopening log files nginx has to do this from inside worker 
processes, and to be able to do so it chown's them to a user under 
which nginx worker processes are running.

Maxim Dounin