# Log files as non root user

**URL:** <https://www.ruby-forum.com/t/log-files-as-non-root-user/242796>\
**Category:** NGINX\
**Created:** [July 28, 2015, 9:16pm UTC](https://www.ruby-forum.com/t/log-files-as-non-root-user/242796 "2015-07-28T21:16:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 28, 2015, 9:16pm UTC](https://www.ruby-forum.com/t/log-files-as-non-root-user/242796/1 "2015-07-28T21:16:18Z")

</div>

Hello Everyone,

I am trying to configure ngnix where logs and pid file are written to a  
custom path and owned as non root. When even I start ngnix these files  
are  
created and owned as root. In ngnix.conf I defined as below. Please  
advise.

user usradmin mwgroup;  
worker\_processes 1;

error\_log /export/local/opt/ngnix/logs/error.log warn;  
pid /export/local/opt/ngnix/logs/nginx.pid;

events {  
worker\_connections 1024;  
}

http {  
include /etc/nginx/mime.types;  
default\_type application/octet-stream;

log\_format main '$remote\_addr - $remote\_user [$time\_local] “$request” ’  
'$status $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

access\_log /export/local/opt/ngnix/logs/access.log main;

sendfile on;  
#tcp\_nopush on;

keepalive\_timeout 65;

#gzip on;

include /etc/nginx/conf.d/\*.conf;  
}

Posted at Nginx Forum:

> **[log files as non root user](https://forum.nginx.org/read.php?2,260593,260593#msg-260593)**
>
> Hello Everyone, I am trying to configure ngnix where logs and pid file are written to a custom path and owned as non root. When even I start ngnix these files are created and owned as root. In ngnix.conf I defined as below. Please advise. user...

---

<div class="post-metadata">

**Author:** ![cskalyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/74df32/32.png) [@cskalyan](https://www.ruby-forum.com/u/cskalyan)\
**Post date:** [July 29, 2015, 3:53pm UTC](https://www.ruby-forum.com/t/log-files-as-non-root-user/242796/2 "2015-07-29T15:53:48Z")

</div>

Hello,

If you start your nginx process with root (login), your master process  
will  
start with root but the “worker process” and “cache manager” with  
usradmin:mwgroup (you can test with this command “ps aux | grep nginx”)

you can try to start nginx with usradmin account : “su - usradmin ;  
/etc/init.d/nginx start”, this will solve the rights issue

Posted at Nginx Forum:

> **[Re: log files as non root user](https://forum.nginx.org/read.php?2,260593,260622#msg-260622)**
>
> Hello Everyone, I am trying to configure ngnix where logs and pid file are written to a custom path and owned as non root. When even I start ngnix these files are created and owned as root. In ngnix.conf I defined as below. Please advise. user...
