As the title says, I have a server where nginx was originally installed by the root user. I now want to run nginx as a non-root user, a new user that I added to both the
When I try to run nginx from this new user, I get the following message:
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2016/08/09 22:07:52 [warn] 17609#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1 2016/08/09 22:07:52 [emerg] 17609#0: open() "/var/log/nginx/access.log" failed (13: Permission denied)
I’m confused why this is an issue—I changed the owner and group of
www-data. The nginx master process user is
root, which I believe is correct, and the sub-processes are running (or trying to run) as
www-data. The file permissions for
error.log and 'access.log` are 755. What am I missing?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
I received some advice that solved my problem and seems to be sound counsel. I’m now starting the server from the non-root account using sudo and all is well. One little trick!
This happened to me because I was running
nginx -tinstead of sudo
nginx -t. Doh!
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now
I ran into this exact problem, which had me stumped for a while. The problem is that nginx needs to execute as root and let the user directive in the /etc/nginx/nginx.conf handle running everything as the correct user. For me, I had the sytemd job defining the user to run nginx as.