2012-01-20 30 views
0

我很抱歉我的noob问题,但我真的不明白什么是错的!Rails 3 - 不加载页面(nginx不启动)

我想在vds上运行我的应用程序。所以,对于我下次使用:

Ubuntu 10.04 
PostgreSQL 9.1 
Rails 3.1.3 
Ruby 1.9.3p27 
Nginx 1.0.11 (installed/compiled by passenger) 
Phusion passenger 3.0.11 
Capistrano 

所以,我试图用已通过脚手架创建小型简单的Rails应用我的配置。所以,这个应用程序工作正常(它使用SQlite并显示所有页面)。

然后我试图启动我的应用程序,它使用PostgreSQL。所以,我通过Capistrano的上载,然后打印

$ cap deploy:start 
* executing `deploy:start' 

,也是我的服务器上我打印

service nginx restart 

所以,当我访问IP我只得到我的旧应用程序的主轨索引页(如果我之前发布了非常简单的应用程序),或者它显示无法连接到服务器(否则),仅此而已。

此外,我试过了:

rails c production 
> app.get("/") 

然后我得到:

User Load (4.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1 
    CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1 
    User Load (0.0ms) SELECT "users".* FROM "users" 
=> 500 

而且,当我尝试启动或重新启动我的应用程序的nginx它不想工作:

$ initctl list | grep nginx 
nginx stop/waiting 
$ service nginx start 
nginx start/running, process 30746 
$ initctl list | grep nginx 
nginx stop/waiting 

出了什么问题?

我的配置文件:

Nginx.conf:

user root; 

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 /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11; 
    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-head/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 localhost; 

     # root and passenger i added. 
     root /vol/www/apps/ror_tutorial/current/public      #/current because of Capistrano 
     passenger_enabled on;   

     #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; 
     } 

     # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
     # 
     #location ~ \.php$ { 
     # proxy_pass http://127.0.0.1; 
     #} 

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
     # 
     #location ~ \.php$ { 
     # root   html; 
     # fastcgi_pass 127.0.0.1:9000; 
     # fastcgi_index index.php; 
     # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
     # include  fastcgi_params; 
     #} 

     # deny access to .htaccess files, if Apache's document root 
     # concurs with nginx's one 
     # 
     #location ~ /\.ht { 
     # deny all; 
     #} 
    } 


    # another virtual host using mix of IP-, name-, and port-based configuration 
    # 
    #server { 
    # listen  8000; 
    # listen  somename:8080; 
    # server_name somename alias another.alias; 

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


    # HTTPS server 
    # 
    #server { 
    # listen  443; 
    # server_name localhost; 

    # ssl     on; 
    # ssl_certificate  cert.pem; 
    # ssl_certificate_key cert.key; 

    # ssl_session_timeout 5m; 

    # ssl_protocols SSLv2 SSLv3 TLSv1; 
    # ssl_ciphers HIGH:!aNULL:!MD5; 
    # ssl_prefer_server_ciphers on; 

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

} 

配置/ deploy.rb

set :user, "root"                
set :rails_env, "production" 

default_run_options[:pty] = true            # Must be set for the password prompt from git to work 
set :repository, "git://github.com/Loremaster/sample_app.git" 

set :application, "ror_tutorial" 
set :deploy_to, "/vol/www/apps/#{application}" 

set :scm, :git 
set :branch, "master" 

server "188.127.224.136", :app, 
          :web, 
          :db, :primary => true 

# if you're still using the script/reaper helper you will need 
# these http://github.com/rails/irs_process_scripts 

# If you are using Passenger mod_rails uncomment this: 
namespace :deploy do 
    task :start do ; end 
    task :stop do ; end 
    task :restart, :roles => :app, :except => { :no_release => true } do 
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" 
    end 
end 

回答

0

我发现什么是错的 - 我忘了';'在此字符串:

Nginx.conf:

root /vol/www/apps/ror_tutorial/current/public 
0

确保你有你的根路线的路线设置文件,然后从公共文件夹中删除index.html,否则它将始终在着陆时呈现页。

+0

我没有索引文件在我的'public'文件夹。另外,路线是正确的。我的应用程序在我的本地机器和heroku.com上效果很好。 – ExiRe

0

我不知道nginx的任何东西,但只是一个提示:

有您设置PostgreSQL的服务器是否正常?