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 gemscould 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 notrequired, i.e. Ruby Enterprise Edition will work fine without them. But mostpeople use Ruby Enterprise Edition in combination with Phusion Passenger andRuby on Rails, which do require one or more of the aforementioned gems, so youmay want to install them later.
To install theaforementioned 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 installrake fastthread capistrano rack
/opt/ree1.8.7/bin/geminstall 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 installpassenger
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 应用
在项目根目录下:
capdeploy:setup # 配置发布环境
cap deploy # 发布
五 . 查看服务器状态
sudo/opt/ree1.8.7/bin/passenger-memory-stats
sudo /opt/ree1.8.7/bin/passenger-status
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com