【发布时间】:2015-08-06 19:15:47
【问题描述】:
我正在 centos 上使用 rails、unicorn 和 nginx 构建应用程序。我对做服务器端的事情很陌生,但我正在尝试follow this tutorial 并让应用程序运行。
这是我的 nginx default.conf 文件:
upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/tmp/unicorn.rqm3.sock fail_timeout=0;
}
server {
listen 8080;
server_name localhost;
root /www/rqm3/;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
这是我的独角兽文件:
# Set the working application directory
# working_directory "/path/to/your/app"
working_directory "/www/rqm3"
# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/www/rqm3/pids/unicorn.pid"
# Path to logs
# stderr_path "/path/to/log/unicorn.log"
# stdout_path "/path/to/log/unicorn.log"
stderr_path "/www/rqm3/log/unicorn.log"
stdout_path "/www/rqm3/log/unicorn.log"
# Unicorn socket
listen "/tmp/unicorn.[app name].sock"
listen "/tmp/unicorn.rqm3.sock"
# Number of processes
# worker_processes 4
worker_processes 2
# Time-out
timeout 30
这是我的 nginx 错误日志
2015/08/06 14:37:44 [crit] 24375#0: *30 connect() to unix:/tmp/unicorn.rqm3.sock failed (13: Permission denied) while connecting to upstream, client: 192.168.2.213, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.rqm3.sock:/", host: "192.168.1.29:8080"
【问题讨论】:
-
愚蠢的问题,但是您是否正在启动您的 Rails(机架)应用程序?另外,你的独角兽文件中的
listen "/tmp/unicorn.[app name].sock"行是错字吗? -
应用启动了,有问题的那行是直接从教程里复制过来的,我试试不看那行,看看有没有什么变化。
-
刚刚添加了错误日志,似乎我没有正确的权限,但我将其设置为“775”
标签: ruby-on-rails nginx unicorn