部署 nginx + passenger 部署 rails 3.2.1 出问题求助!

kaka · February 06, 2012 · Last by AlphaLiu replied at February 06, 2012 · 4681 hits

这个是不是项目的路由设置问题....

没有开启索引吧?

把 conf 发出来看看吧。

passenger_enable 没有设置

#1 楼 @metal

user root staff;
worker_processes  10;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    passenger_root /Users/kaka/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.10;
    passenger_ruby /Users/kaka/.rvm/wrappers/ruby-1.9.2-p290/ruby;

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

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        root /Users/kaka/Documents/Test/Dom/public;   # <--- be sure to point to 'public'!
        passenger_enabled on;
        index index index.html index.htm;

        location ~ ^/assets/ {
          expires 1y;
          add_header Cache-Control public;

          add_header ETag "";
          break;
        }

        location  /  {
            autoindex  on;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
location  /  {
  autoindex  on;
}

这段去掉

果然是开启了索引 = =

#6 楼 @metal 为什么我把 root 路径指定到别外项目路径就出现 500 错误,这是我那个项目问题吗?

#7 楼 @kaka

没看明白。比如改成这样了?

root /Users/kaka/Documents/Test/Dom/public2; 

rails 的默认的访问地址是 public,如果要改需要该 rails 配置,这个我没有改过,@huacnlee 应该知道。

#8 楼 @metal 我就是 root /Users/kaka/Documents/Test/Dom1/public 另外一个项目

#9 楼 @kaka

server {
        listen       80;
        server_name  localhost;

        root /Users/kaka/Documents/Test/Dom/public;   # <--- be sure to point to 'public'!
        root /Users/kaka/Documents/Test/Dom1/public;   # <--- be sure to point to 'public'!
        passenger_enabled on;
        ...
        }

别告诉你现在是这样的吧?

@metal 本来是这样的 root /Users/kaka/Documents/Test/Dom/public 我把他修改指定到另外一个项目 root /Users/kaka/Documents/Test/Dom1/public 是修改不是添加...

@metal

server {
        listen       80;
        server_name  localhost;

        root /Users/kaka/Documents/Test/Dom1/public;   # <--- be sure to point to 'public'!
        passenger_enabled on;
        ...
        }

修改 root 到另外一个项目..

重启 nginx 和应用吧 = =;

#11 楼 @kaka

#13 楼 @metal 还是一样...

touch tmp/restart.txt

在 dom1 根目录这样,也不管用么。

我 rails s -e production 运行项目 也是 500 错误 但是 rails s 就正常 #15 楼 @metal touch 不管用

#16 楼 @kaka 好吧

rake:db:create:all

#17 楼 @metal 不行 不知道是我项目那些东西没有编译到... 应该是项目的问题

#18 楼 @kaka 把 logs/production.log 发出来看看吧。我真的很想知道为什么。

config.assets.compile = true 把这个预编译开启就可以了 #19 楼 @metal

我一般到把下面这段去掉了 ··· index index index.html index.htm;

location ~ ^/assets/ { expires 1y; add_header Cache-Control public;

add_header ETag ""; break; }

location / { autoindex on; }

error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } ··· 还有我加了一句·rails_env development;·

You need to Sign in before reply, if you don't have an account, please Sign up first.