2012-10-14 125 views
3

我是一個新手,喜歡語言和開發環境。然而,當我不使用PostgreSQL和/或Heroku的時候,我試圖將一個新的應用程序推送到生產環境,我感到非常沮喪。在Ubuntu 12.04 for Rails 3.2.8環境下設置Nginx和Passenger環境

由於工作相關的原因,我們使用一個以MySQL作爲數據庫的rackspace雲服務器。

我的挫折感來自搭乘乘客和Nginx。我已經按照Ryan的Railscasts上的deploying to vpsthis教程。

我可以通過在服務器上安裝ruby,mysql,passenger,Nginx,依賴項和rails。但是當我嘗試啓動Nginx時,沒有任何反應。當我說沒有任何反應時,我的意思是我沒有任何跡象表明它正在運行。我將瀏覽器指向IP地址,並在瀏覽器中出現「此網頁不可用」的標準錯誤。我看過錯誤日誌,它是空白的。我還沒有部署我的應用程序...只是想看看Nginx的默認屏幕。

任何想法?我猜測在配置Nginx時我缺少一個關鍵步驟,我只是不知道它是什麼。

我的訪問日誌

.0.0.1 - - [14/Oct/2012:10:40:03 -0500] "GET/HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)" 
127.0.0.1 - - [14/Oct/2012:10:45:03 -0500] "GET/HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)" 
127.0.0.1 - - [14/Oct/2012:10:50:03 -0500] "GET/HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)" 
127.0.0.1 - - [14/Oct/2012:10:55:03 -0500] "GET/HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)" 
127.0.0.1 - - [14/Oct/2012:11:00:03 -0500] "GET/HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)" 

我Nginx.conf文件

user deployer staff; 
#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 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.17; 
    passenger_ruby /usr/local/bin/ruby; 

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

    sendfile  on; 
    #tcp_nopush  on; 

    #keepalive_timeout 0; 
    keepalive_timeout 65; 

    #gzip on; 

    server { 
     listen  80; 
     server_name localhost; 

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

} 

回答

5

從我的博客文章這是在這個確切的設置http://blog.nikoroberts.com/post/45834702235/setting-up-a-rails-32-server-in-the-rackspace

你至少缺少 passenger_enabled on;幾乎

我的nginx.conf

worker_processes 4; 

events { 
    worker_connections 1024; 
} 

http { 
    passenger_root /home/deployer/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17; 
    passenger_ruby /home/deployer/.rvm/wrappers/ruby-1.9.3-p194/ruby; 

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

    sendfile  on; 

    keepalive_timeout 65; 

    client_max_body_size 5M; 

    gzip on; 
    gzip_http_version 1.1; 
    gzip_comp_level 1; 
    gzip_disable "MSIE [1-6]\.(?!.*SV1)"; 
    gzip_proxied any; 
    gzip_vary on; 
    gzip_min_length 500; 
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
    passenger_default_user deployer; 
    #fast passenger respawn 
    passenger_pool_idle_time 1000; 

    server { 
    listen 80; 
    charset utf-8; 
    server_name localhost; 
    root /var/www/contactguru/current/public; 
    passenger_enabled on; 
    rails_env production; 

    # fast passenger and rails respawn 
    # from http://stackoverflow.com/a/2329221 
    rails_spawn_method smart; 
    rails_app_spawner_idle_time 0; 
    rails_framework_spawner_idle_time 0; 

    location ~ ^/(assets)/ { 
     root /var/www/contactguru/current/public; 
     gzip_static on; 
     expires max; 
     add_header Cache-Control public; 
     # access_log /dev/null; 
    } 
    } 
} 
+0

謝謝...我簡直不敢相信我錯過了。這工作。 – DaveG