ilia
ilia

Reputation: 1333

Nginx creates log files on behalf of root

Finaly, I've succeeded to start nginx.
Now, it creates log files on behalf of root.
So, are there any thoughts why it is happenning and how can I fix it?
The first line of nginx.conf is user nginx;

Upvotes: 2

Views: 2446

Answers (2)

ilia
ilia

Reputation: 1333

So, I've managed to fix that.
Actually, the solution is the same as in my prequel question:

# put SELinux in permissive mode
setenforce 0
# send USR1 signal to nginx master process
# master process reopens files, does chown() and chmod() to enable
# the worker processes to write to files, and send a notification to
# the worker procesess, so they reopen files instantly
# you can find the path to the nginx pid file in the nginx.conf
kill -USR1 `cat /var/run/nginx.pid`
# create SELinux module
grep nginx /var/log/audit/audit.log | audit2allow -M nginx
# apply module
semodule -i nginx.pp
# put SELinux back in enforcing mode
setenforce 1
# remove SELinux module files
rm -rf nginx.{pp,te}

Upvotes: 1

Adam Birds
Adam Birds

Reputation: 434

The problem may be that the permissions of the directory are set differently try placing logs somewhere within doc root so you can test if it is a permission problem. Update me with your findings and I may be able to help

Upvotes: 0

Related Questions