2012-09-16 52 views
4

部署導軌這是我第一次部署Rails應用程序,我尋找的過程很沮喪。由於工作原因,我們使用Rackspace雲與Ubuntu 12.04 LTS(精確穿山甲)和MYSQL,而不是Heroku路線。與Capistrano的+ Nginx的+乘客+ MYSQL到VPS

我一直在試圖弄清楚這一點爲兩天以上,我終於轉向社區尋求幫助。目前我得到了「我的服務器上發現404錯誤」

我跟隨了Ryan的Screencasts「部署到VPS」,「Capistrano食譜」,this tutorial,以及其他在谷歌等等,我是還不夠。

我設法安裝以下軟件:

  • Node.js的
  • RVM
  • 紅寶石1.9.3p194(2012-04-20修訂35410)x86_64的Linux的]
  • 的Rails 3.2.8
  • MYSQL
  • 客運
  • Nginx的

我敢肯定,我失去了一些東西簡單的在我的Capistrano的部署位置:

require "bundler/capistrano" 

server "198.101.242.242", :web, :app, :db, primary: true 

set :application, "myapp" 
set :user, "deployer" 
set :deploy_to, "/home/#{user}/#{application}" 
set :deploy_via, :remote_cache 
set :use_sudo, false 

set :scm, "git" 
set :repository, "[email protected]:xxxx/#{application}.git" 
set :branch, "master" 

default_run_options[:pty] = true 
ssh_options[:forward_agent] = true 

# if you want to clean up old releases on each deploy uncomment this: 
after "deploy", "deploy:cleanup" 

# 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 

有什麼我應該在部署之前在做什麼?

以下是Nginx的錯誤日誌:

2012/09/16 23:22:17 [error] 13939#0: *1 "/home/deployer/myapp/public/index.html" is not found (2: No such file or directory), client: ip, server: localhost, request: "GET/HTTP/1.1", host: "ip" 
2012/09/16 23:22:17 [error] 13939#0: *1 open() "/home/deployer/myapp/public/favicon.ico" failed (2: No such file or directory), client: ip, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "65.61.189.109" 
2012/09/16 23:22:19 [error] 13939#0: *1 "/home/deployer/myapp/public/index.html" is not found (2: No such file or directory), client: ip, server: localhost, request: "GET/HTTP/1.1", host: "ip" 
2012/09/16 23:22:19 [error] 13939#0: *1 open() "/home/deployer/myapp/public/favicon.ico" failed (2: No such file or directory), client: ip, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "ip" 

的Nginx服務器的配置文件:

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

    #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; 
     location/{ 
      root /home/deployer/myapp/public; # <--- be sure to point to 'public'! 
     } 
     passenger_enabled on; 

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

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

    # server { 
    # listen 80; 
    # server_name localhost; 
    #  location/{ 
    #   root /home/deployer/myapp/public; # <--- be sure to point to 'public'! 
    # } 
    #  passenger_enabled on; 
    # } 


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

} 

感謝。

+0

您是否嘗試將應用程序的nginx配置放置在新的服務器塊中?我記得我遇到過類似的事情。 – maru

+0

感謝您的建議,我只是根據您的評論嘗試過,但沒有奏效。 – DaveG

+0

我不確定日誌文件中「客戶」IP地址的用途是什麼。這是不正確的。我不知道這是從哪裏來 – DaveG

回答

2

好了,所以我結束了試錯和Beef Jerky's評論搞清楚的問題。

第一個問題是Capistrano的無法從我的應用程序,它必須依賴安裝一些寶石的。所以我安裝了那些生產......特別是rvm capistrano寶石和rmagick。 RVM Capistrano寶石是我在解散時遇到的主要問題和原因。 rmagick是在修復了我通過安裝依賴項解決的rvm問題之後發佈的。

我在指着我的apps文件夾的myapp /公衆,而不是當前版本的myapp在Nginx的服務器配置文件/電流/公共第二個問題。所以我保留了現有的服務器模塊,並將其設置放入其中,然後運行。以下是Nginx服務器配置文件的設置:

server { 

     listen 80; 
     server_name localhost; 
     root /home/deployer/banking_analytics/current/public; # <--- be sure to point to 'public'! 
     passenger_enabled on; 

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

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

    # server { 
    # listen 80; 
    # server_name localhost; 
    #  location/{ 
    #   root /home/deployer/banking_analytics/public; # <--- be sure to point to 'public'! 
    # } 
    #  passenger_enabled on; 
    # } 


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

} 
+0

您的答案或問題都不會變得簡潔。你有沒有機會爲後代編輯它們? –

+0

我已經更新了答案。我希望澄清。 – DaveG

+0

「myapp/current/public」文件夾來自哪裏?我只有「myapp/public」 – MauroPorrasP