我当前想在我的导轨设置中使用nginx。我已将配置文件放置在目录RAILS_ROOT/config/nginx
中。这是我的配置文件,名为development.conf
和mime.types
-File。
我想将日志放在 RAILS_ROOT/log
-directory中。
这是我的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
我做错了吗?
http://nginx.org/en/docs/ngx_core_module.html#error_log指示:
- 默认值是
error_log logs/error.log error;
- 要进行调试日志起作用,需要使用-with-debug构建nginx。
正在发生的事情是您要陷入默认值,我没有发现任何语法错误,所以我的猜测是您的nginx不会与 - with-debug一起编译。
您可以使用nginx -V
检查(注意:是资本V)
on mac 它在
中/usr/local/logs/error.log
我在运行后找到了这一点:
nginx -V
配置参数: - prefix =/usr/local -with-cc-opt = -wno-deprecated-declarations -with-with-with-http_ssl_module -add-module = ../nginx-rtmp-module/