Rails 部署: Rails 2.3.4,REE 1.8.7, Nginx+Passenger, Caps2.5,SVN

Rails 部署

Rails 2.3.4, Ruby  Enterprise Edition  1.8.7, Nginx+Passenger, Capstranio2, svn

开发机: windows

部署: linux(redhat)

 

.ruby企业版安装

     1.在http://www.rubyenterpriseedition.com/下载最新版本,目前的1.8.7-20090928,是一个tar

     2.运行tar zxf ruby-enterprise-1.8.7-20090928.tar.gz,解开目录

     3.在解开的目录中运行sudo ./installer,如果系统中的gcc版本太低的话,则编译时会出错。这是需要删除installer.rb source/distro/installer.rb中的 "-fno-stack-protector"选项。 安装过程中需要连接internet,如果没有连接,则安装结束后会出现如下提示:

 

The following gems could not be installed, probably because of an Internet

connection error:

 

 * passenger

 * rake

 * rails

 * fastthread

 * rack

 * mysql -- --with-mysql-config='/usr/bin/mysql_config'

 * sqlite3-ruby

 * postgres

 

These gems are not required, i.e. Ruby Enterprise Edition will work fine without them. But most people use Ruby Enterprise Edition in combination with Phusion Passenger and Ruby on Rails, which do require one or more of the aforementioned gems, so you may want to install them later.

 

To install the aforementioned gems, please use the following commands:

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install passenger

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install rake

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install rails

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install fastthread

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install rack

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install mysql -- --with-mysql-config='/usr/bin/mysql_config'

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install sqlite3-ruby

  * /opt/ree1.8.7/bin/ruby /opt/ree1.8.7/bin/gem install postgres

     4. 运行 /opt/ree1.8.7/bin/ruby -v 查看是否安装成功

     5. 安装应用需要的gem

             sudo chown -R rails /opt/ree1.8.7

              /opt/ree1.8.7/bin/gem install rake fastthread capistrano rack

              /opt/ree1.8.7/bin/gem install  ruby-oci8  -v 1.0.6

               /opt/ree1.8.7/bin/gem install activerecord-oracle-adapter --source http://gems.rubyonrails.org

 

            

.nginx+passenger安装

     1.安装passenger

               /opt/ree1.8.8/bin/gem install passenger

     2.安装nginx

              sudo /opt/ree1.8.7/bin/passenger-install-nginx-module

     3.配置nginx

            

worker_processes  1;

 

events {

    worker_connections  4096;

}

 

http {

    passenger_root /opt/ree1.8.7/lib/ruby/gems/1.8/gems/passenger-2.2.5;

    passenger_ruby /opt/ree1.8.7/bin/ruby;

    passenger_max_pool_size 30;

 

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

 

    server {

        listen       6789;

        server_name  232.228.29.197;

        root /home/rails/apps/BssEx2/current/public;

        passenger_enabled on;

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

}

            

.capstranio2配置

     

set :application, "BssEx2"

set :repository,  "svn://232.239.9.124/bss/public/BssEx2/trunk"

 

set :deploy_to, "/home/rails/apps/#{application}"

set :checkout, "export"

set :use_sudo, false

 

role :app, "232.228.29.197"

role :web, "232.228.29.197"

 

set :user, "rails"

set :password, "mypass"

 

namespace :deploy do

  task :start, :roles => :app do

    run "touch #{current_release}/tmp/restart.txt"

  end

 

  task :stop, :roles => :app do

    # Do nothing.

  end

 

  desc "Restart Application"

  task :restart, :roles => :app do

    run "touch #{current_release}/tmp/restart.txt"

  end

end

 

.发布Rails应用

 

       在项目根目录下:

          cap deploy:setup  #配置发布环境

          cap deploy             #发布

 

.查看服务器状态

        sudo /opt/ree1.8.7/bin/passenger-memory-stats

        sudo /opt/ree1.8.7/bin/passenger-status

你可能感兴趣的:(nginx,SVN,git,Ruby,Rails)