部署 Nginx + Passenger 本机部署问题

Blues · 2015年01月06日 · 最后由 Blues 回复于 2015年01月06日 · 5213 次阅读

最近刚开始用这个,很多不太明白。

首先配置如下:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    passenger_root /Users/blues/.rvm/gems/ruby-2.2.0-preview2/gems/passenger-4.0.57;
    passenger_ruby /Users/blues/.rvm/gems/ruby-2.2.0-preview2/wrappers/ruby;

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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  bluesrailsblog.com;
        root /Users/blues/Documents/ror/blog/public;
        passenger_enabled on;
        #rails_env development;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #location / {
        #root   html;
        #    index  index.html index.htm;
        #}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

遇到的问题是:如果按照这样的配置,会出现错误,错误日志:

2015/01/06 10:08:35 [alert] 44986#0: *12 Cannot stat '/Users/blues/Documents/ror/blog/config.ru; This error means that the Nginx worker process (PID 44986, running as UID -2) does not have permission to access this file. Please read the manual to learn how to fix this problem: section 'Troubleshooting' -> 'Upon accessing the web app, Nginx reports a "Permission denied" error'; Extra info, client: 127.0.0.1, server: bluesrailsblog.com, request: "GET / HTTP/1.1", host: "bluesrailsblog.com"

1.如果把

#location / {
        #root   html;
        #    index  index.html index.htm;
        #}

的注释取消,就没有问题,但是总是会出现 Nginx 的欢迎界面,而不是我在 routes.rb 里面设置的 root 路由页面,我把 nginx 里面的 index 页面删除之后就出现

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

2. 如果把

#user  nobody;

取消注释变为

user  root; 或者 user root root;就出现错误:
nginx: [emerg] getgrnam("root") failed in /usr/local/nginx/conf/nginx.conf:2

参考了 2 个帖子 https://ruby-china.org/topics/2873 https://ruby-china.org/topics/458 均没有解决问题,求指导,谢谢!

到现在还是没找到办法,@Rei,求帮助啊

需要 登录 后方可回复, 如果你还没有账号请 注册新账号