Closed vtemian closed 10 years ago
By default, nginx has an error_log path which is given at compile time(default /var/log/nginx/error.log
). Unless overwritten in the main section, it will try to log to the default path.
access_log
on the other hand, it's per server and if it's not writable is logged as error(not critical).
So, not being able to write the error log in the main section, cause nginx to fail with critical
2013/11/20 11:57:22 [emerg] 3865#0: open() "/var/log/nginx/error.log" failed (13: Permission denied)
As per the nginx docs:
syntax: error_log file | stderr | syslog:server=address[,parameter=value] [debug | info | notice | warn | error | crit | alert | emerg]; default: error_log logs/error.log error;
Did you actually experience this error, or where you suggesting this preventively?
Otherwise, can you please tell me how to reproduce this? As an experiment I ran nginx as default user, made it blow up at boot time, and it did generate a logs/error.log
file in the project's directory.
Thanks.
I also found some outdated docs which state:
Also note that as of version 0.7.53, nginx will use a compiled-in default error log location until it has read the config file. If the user running nginx doesn't have write permission to this log location, nginx will raise an alert like this:
[alert]: could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
As per this though, the compiled-in default error log location will be used until it has read the config file. Hence, what good would it be to move the error_log
in the said config file as per your suggestion?
Let me know your thoughts.
Well, using nginx version: nginx/1.4.3
# ===================================================================== #
# THIS FILE IS AUTO GENERATED. DO NOT MODIFY. #
# IF YOU CAN SEE IT, THERE PROBABLY IS A RUNNING SERVER REFERENCING IT. #
# ===================================================================== #
pid tmp/development-nginx.pid;
# This number should be at maxium the number of CPU on the server
worker_processes 4;
events {
# Number of connections per worker
worker_connections 4096;
}
http {
# use sendfile
sendfile on;
# Gin initialization
lua_code_cache off;
lua_package_path "./?.lua;$prefix/lib/?.lua;#{= LUA_PACKAGE_PATH };;";
server {
# List port
listen 3001;
# Access log with buffer, or disable it completetely if unneeded
access_log logs/development-access.log combined buffer=16k;
# access_log off;
# Error log with buffer
error_log logs/development-error.log;
# Gin
location / {
content_by_lua 'require(\"gin.core.router\").handler(ngx)';
}
location /ginconsole {
content_by_lua 'require(\"gin.cli.api_console\").handler(ngx)';
}
}
}
I've got 2013/11/20 11:57:22 [emerg] 3865#0: open() "/var/log/nginx/error.log" failed (13: Permission denied)
So you're basically using the autogenerated nginx.conf
file with nginx
instead of ngx_openresty
?
If I can't see it / reproduce it, I can't fix it / accept it. Still don't know what OS you're running it in. Assuming OSX?
r.
Yeap , I'm using autogenerated nginx.conf
file with nginx
on Ubuntu 12.04.3 LTS
.
I understand your point of view and thanks for details responses and would be awesome if you can make it work on nginx
also.
Gin just doesn't run in pure nginx
, so not seeing the point here, but will do my best.
Good luck :+1:
error_log
points at a subdirectory of your project, so why moving error_log changes any permission issues? What OS are you running this in?BTW, I see you only moved
error_log
, but notaccess_log
, are these behaving differently?