为什么NGINX默认要使用./logs/error.log?

4

我目前希望在我的Rails设置中使用NGINX。我已经将配置文件放置在目录RAILS_ROOT/config/nginx中。这是我放置的名为development.confmime.types的配置文件。

我希望将日志放置在RAILS_ROOT/log目录中。

这是我的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;
    }
  }
}

我正在使用以下命令从我的RAILS_ROOT启动NGINX:

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

我遇到了以下错误:

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

我的版本如下:

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

我做错了什么吗?

2个回答

9
在MAC上,它位于:
/usr/local/logs/error.log 

运行后我找到了这个:

nginx -V 

配置参数: --prefix=/usr/local --with-cc-opt=-Wno-deprecated-declarations --with-http_ssl_module --add-module=../nginx-rtmp-module/


9

http://nginx.org/en/docs/ngx_core_module.html#error_log表明:

  1. 默认值为error_log logs/error.log error;
  2. 要使调试日志正常工作,需要使用--with-debug编译nginx。

现在发生的情况是你正在使用默认值,我没有发现任何语法错误,所以我的猜测是你的nginx未使用--with-debug编译。

可以使用nginx -V(注意:大写的V)来检查它。


你如何使用调试编译它?需要再次卸载/安装nginx吗? - Computer's Guy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接