Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is NGINX wanting to use ./logs/error.log as default?

Tags:

nginx

osx-lion

I am currently wanting to use NGINX in my Rails setup. I have placed the configuration files in the directory RAILS_ROOT/config/nginx. Here is my config-file placed named development.conf and the mime.types-file.

I am wanting to place my logs in the RAILS_ROOT/log-directory.

This is my development.conf:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;

  # main access log
  access_log log/nginx.access.log;

  # main error log
  error_log log/nginx.error.log debug;

  sendfile      on;

  keepalive_timeout  65;

  server {
    listen 9001; #omg!
    server_name local.woman.dk;

    rewrite ^/(.*)/$ /$1 last;

    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_max_temp_file_size  0;

    location / {
      ssi on;
      proxy_pass http://127.0.0.1:3000;
    }
  }
}

I am starting NGINX from my RAILS_ROOT with this command:

nginx -p . -c config/nginx/development.conf

And I get the following error:

nginx: [alert] could not open error log file: open() "./logs/error.log" failed (2: No such file or directory)

My version is this:

[(master)]=> nginx -v
nginx version: nginx/1.2.4

Am I doing anything wrong?

like image 719
Kasper Grubbe Avatar asked Dec 02 '22 21:12

Kasper Grubbe


1 Answers

http://nginx.org/en/docs/ngx_core_module.html#error_log indicates that:

  1. the default value is error_log logs/error.log error;
  2. that for debug logging to work, nginx needs to be built with --with-debug.`

what's happening is that you're falling through to the default value, I'm not spotting any syntax errors so my guess is that your nginx is not compiled with --with-debug.

you can check that with the nginx -V (note: that's capital V)

like image 186
cobaco Avatar answered Dec 15 '22 16:12

cobaco