Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 /etc/nginx/nginx.conf

user Foo; worker_processes 1;  error_log /home/Foo/log/nginx/error.log; pid /home/Foo/run/nginx.pid;  events {     worker_connections 1024;     use epoll; }  http {     access_log /home/Foo/log/nginx/access.log;      server {         listen 80;          location = / {             proxy_pass http://192.168.0.16:9999;         }     } } 

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

When I re-start Linux it seems to work, Nginx 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/nginx.pid" failed (13: Permission denied) nginx: configuration file /etc/nginx/nginx.conf test failed 

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

Why does it try to access another error log file?

like image 833
SangminKim Avatar asked Dec 14 '15 02:12

SangminKim


People also ask

How do I change the error log in nginx?

Syntax of error_log in Nginx: For configuring the error_log, you have to add the path of the log file and set the log level. If you do not set the second parameter, then the error_log will take “error” as its default log level: error_log /var/log/nginx/error.

How do I open nginx error log?

log and the error log is located at /var/log/nginx/error. log . Nginx logs file default path depends on the operating system and installation. You can override the default settings and change the format of logged messages by editing the NGINX configuration file /etc/nginx/nginx.

Does nginx log by default?

NGINX writes information about encountered issues of different severity levels to the error log. The error_log directive sets up logging to a particular file, stderr , or syslog and specifies the minimal severity level of messages to log. By default, the error log is located at logs/error.


1 Answers

You might need to fire it with sudo

sudo nginx -t 
like image 166
T.Todua Avatar answered Oct 12 '22 17:10

T.Todua