六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 127|回复: 0

Red Hat Enterprise Linux 环境passenger多ruby版本共存部署

[复制链接]

升级  14%

66

主题

66

主题

66

主题

举人

Rank: 3Rank: 3

积分
242
 楼主| 发表于 2013-1-30 01:26:31 | 显示全部楼层 |阅读模式
1.安装rvm
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ git clone git://github.com/wayneeseguin/rvm.git cd rvm && ./install  2.修改用户配置文件.bashrc,添加一行代码:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 3.重启Terminal.
查询当前版本:rvm info  
列出版本:rvm list
更多命令,访问 http://rvm.beginrescueend.com/rvm/  
 
4.安装 ruby
4.1.安装REE
rvm install ree
4.2.安装 ruby-1.9.2

rvm install ruby-1.9.2-p180
小技巧:用工具下载好ruby-enterprise-1.8.7-2011.03.tar.gz,ruby-1.9.2-p180.tar.bz2,yaml-0.1.3.tar.gz,然后手工放到~/.rvm/archives 目录下,再运行安装命令,可以直接解压安装。
 
5.将某一个版本的ruby设为默认
$ rvm --default use 1.9.2   #设置1.9.2为默认版本$ rvm default      #通过default可以快速回到默认版本$ rvm list default     #查看当前版本设置信息$ rvm reset     #恢复系统默认设置    
6.安装rails
6.1.安装rails2
$ rvm ree-1.8.7-2011.03$ rvm gemset create rails2$ rvm genset use rails2$ gem install --no-ri --no-rdoc rails -v=2.3.12 6.2.安装rails3
$ rvm ruby-1.9.2-p180$ rvm gemset create 'rails3'$ rvm gemset use rails3$ gem install railsSuccessfully installed activesupport-3.0.9Successfully installed builder-2.1.2Successfully installed i18n-0.5.0Successfully installed activemodel-3.0.9Successfully installed rack-1.2.3Successfully installed rack-test-0.5.7Successfully installed rack-mount-0.6.14Successfully installed tzinfo-0.3.28Successfully installed abstract-1.0.0Successfully installed erubis-2.6.6Successfully installed actionpack-3.0.9Successfully installed arel-2.0.10Successfully installed activerecord-3.0.9Successfully installed activeresource-3.0.9Successfully installed mime-types-1.16Successfully installed polyglot-0.3.1Successfully installed treetop-1.4.9Successfully installed mail-2.2.19Successfully installed actionmailer-3.0.9Successfully installed thor-0.14.6Successfully installed rdoc-3.6.1Successfully installed railties-3.0.9Successfully installed bundler-1.0.15Successfully installed rails-3.0.924 gems installed 7.创建别名
$ rvm alias create ree ree-1.8.7-2011.03 #为ree-187的Ruby版本创建一个别名叫:ree$ rvm alias create ruby192 ruby-1.9.2-p180$ rvm use ree #通过别名迅速切换$ rvm delete ree #删除别名 $ rvm alias list # 查看所有的别名  
9.使用gemset
$ rvm use ree@rails2$ rvm use ruby192@rails3 --default   #设置默认 
10.安装passenger
$ gem install passenger$ rvm wrapper 1.9.2 passenger$ passenger-install-nginx-module# Passenger will help you install nginx, the folder is in /opt/nginxDownloading Nginx...# wget -O /tmp/root-passenger-12180/nginx.tar.gz http://sysoev.ru/nginx/nginx-1.0.0.tar.gz--------------------------------------------Nginx with Passenger support was successfully installed.The Nginx configuration file (/opt/nginx/conf/nginx.conf)must contain the correct configuration options in order for Phusion Passengerto function correctly.This installer has already modified the configuration file for you! Thefollowing configuration snippet was inserted:  http {      ...      passenger_root /usr/local/rvm/gems/ruby-1.9.2-p180@rails3/gems/passenger-3.0.7;      passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p180@rails3/ruby;      ...  }After you start Nginx, you are ready to deploy any number of Ruby on Railsapplications on Nginx.Press ENTER to continue.--------------------------------------------Deploying a Ruby on Rails application: an exampleSuppose you have a Ruby on Rails application in /somewhere. Add a server blockto your Nginx configuration file, set its root to /somewhere/public, and set'passenger_enabled on', like this:   server {      listen 80;      server_name www.yourhost.com;      root /somewhere/public;   # <--- be sure to point to 'public'!      passenger_enabled on;   }   
11.设置IP和App
11.1.单个网卡eth1配置多个ip地址
ifconfig eth1:0 192.168.56.101 netmask 255.255.255.0 upifconfig eth1:1 192.168.56.102 netmask 255.255.255.0 uphttp://wuhuizhong.iteye.com/blog/780604
 
11.1.设置demo2(ree@rails2)
cd /opt/rails_apps/
rails demo2
cd demo2

11.2.设置demo3(ruby192@rails3)
cd /opt/rails_apps/
rails new demo3
cd rails3
passenger start -a 127.0.0.1 -p 3001 -d
(此命令执行俩次,详细信息见passenger.zip)
Downloading Nginx...# wget -O /tmp/root-passenger-standalone-3917/nginx-1.0.0.tar.gz http://nginx.org/download/nginx-1.0.0.tar.gz--15:40:02--  http://nginx.org/download/nginx-1.0.0.tar.gzResolving nginx.org... 81.19.68.137Connecting to nginx.org|81.19.68.137|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 654760 (639K) [application/octet-stream]Saving to: `/tmp/root-passenger-standalone-3917/nginx-1.0.0.tar.gz'100%[=======================================>] 654,760     56.7K/s   in 19s    15:40:21 (34.2 KB/s) - `/tmp/root-passenger-standalone-3917/nginx-1.0.0.tar.gz' saved [654760/654760]Installing Phusion Passenger Standalone...[*********************************************] Copying files...               All done!=============== Phusion Passenger Standalone web server started ===============PID file: /opt/rails_apps/demo3/tmp/pids/passenger.3001.pidLog file: /opt/rails_apps/demo3/log/passenger.3001.logEnvironment: developmentAccessible via: http://127.0.0.1:3001/Serving in the background as a daemon.===============================================================================  
12.配置nginx
http{...    passenger_root /usr/local/rvm/gems/ruby-1.9.2-p180@rails3/gems/passenger-3.0.7;    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p180@rails3/ruby;     server {        listen 80;        server_name 192.168.56.101;         root /opt/rails_apps/demo2/public;        passenger_enabled on;        rails_env development;    }    server {        listen 80;        server_name 192.168.56.102;        root /opt/rails_apps/demo3/public;        location / {          proxy_pass http://127.0.0.1:3001;          proxy_set_header Host $host;        }    }} 启动:/opt/nginx/sbin/nginx
停止:/opt/nginx/sbin/nginx -s stop
访问:
rails2:http://192.168.56.101/
rails3:http://192.168.56.102/
 
13.直接通过项目名称访问,在/etc/hosts中添加:
192.168.56.101 demo2192.168.56.102 demo3 
 
 
 
 
===========================================================
参考:
 
RVM中文使用指南
http://lanvige.iteye.com/blog/857501
 
http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/
 
nginx开机自动启动脚本
http://yangzhiping.com/tech/ubuntu-ree-nginx-passenger-rails3.blog.html
# /etc/init.d/nginx stop
# /etc/init.d/nginx start
 
服务器部署之 ruby1.9.2+rails3+nginx+passenger+postgresql
http://thoughtrails.com/episodes/4-deployment-of-production-enviroment-ruby-1-9-2-rails-3-nginx-passenger-and-postgresql-with-rvm
 
在RHEL上安裝設置ROR(nginx+passenger+ruby+rails+oracle+netzke)
http://wuhuizhong.iteye.com/blog/870331
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表