Nginx – centos 7 : nginx givers error when enabling log

centosconfloggingnginxpermissions

In CentOS 7, if I put the following line in my nginx.conf:

error_log /usr/share/nginx/wordpress.itzgeek.com/logs/error.log;

I get the following error when restarting nginx:

nginx: [emerg] open() "/usr/share/nginx/wordpress.itzgeek.com/logs/access.log" failed (13: Permission denied)

user is set to 'nginx' in my nginx.conf

and I restart nginx using this command: systemctl status nginx.service
Also Im logged in as root.

nginx master process is running as root and worker is running as nginx.

Any ideas? I don't understand what's wrong..

Best Answer

Like the log message said it's likely a permissions problem. Change it to a location that nginx can write to, something like this

error_log /var/log/nginx/wordpress.itzgeek.com/error.log;