asleea asleea -4 years ago 434
Linux Question

Nginx still try to open default error log file even though I set nginx config file while reloading

The below is my nginx configuration file located in


user Foo;
worker_processes 1;

error_log /home/Foo/log/nginx/error.log;
pid /home/Foo/run/;

events {
worker_connections 1024;
use epoll;

http {
access_log /home/Foo/log/nginx/access.log;

server {
listen 80;

location = / {

As you can see I change log, pid files location into home directory.

When I re-start
it seems to work,
records error logs in the file I set and pid file also.

However, when it tries
nginx -s reload
or the other, It tries to open other error log file.

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2015/12/14 11:23:54 [warn] 3356#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2015/12/14 11:23:54 [emerg] 3356#0: open() "/home/Foo/run/" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed

I know, I can solve permission error with
but the main issue in here is a error log file(
) Nginx tries to open.

Why does it try to access another error log file?

Answer Source

Check the permissions on the directory /home/Foo/log/nginx/. It must be writable by nginx. Set permissions like so:

sudo chmod 766 /home/Foo/log/nginx
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download