* CentOS 5
* ruby 1.8.6
* gems 1.0.1
gem update --system
* rails 2.0.2
* mongrel-1.0.1
yum install mongrel
* mongrel_cluster-0.2.2
yum install mongrel_cluster
#yum install ruby
#wget
http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
# tar xvfz rubygems-0.9.0.tgz
# ruby /rubygems-0.9.0/setup.rb
#gem install rails
http://rubycgi.org/
一,複数の Rails アプリケーションは Mongrel で同時に提供する
http://example.com/app1
http://example.com/app2
# cd $APP0_DIR
# mongrel_rails start -d -p 3000 -e production --prefix /app0
停止命令:
# mongrel_rails stop
# cd $APP1_DIR
# mongrel_rails start -d -p 3001 -e production --prefix /app1
# cd $APP2_DIR
# mongrel_rails start -d -p 3002 -e production --prefix /app2
# vim /etc/httpd/conf.d/proxy.conf
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /app0 http://localhost:3000/app0
ProxyPassReverse /app0 http://localhost:3000/app0
ProxyPass /app1 http://localhost:3001/app1
ProxyPassReverse /app1 http://localhost:3001/app1
ProxyPass /app2 http://localhost:3002/app2
ProxyPassReverse /app2 http://localhost:3002/app2
2,集群部署
# cd $APP_DIR
# mongrel_rails cluster::configure -p 3000 -e production -N 4
# mongrel_rails cluster::start
# mongrel_rails cluster::stop
vi /etc/httpd/conf
<VirtualHost *:80>
ServerName
www.example.com
ServerAlias
www.example.com
DocumentRoot /home/rails_projects/app
<Directory "/home/rails_projects/app">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteRule (.*) $1 [L]
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / balancer://mongrel_cluster/ stickysession=_exam_session_id nofailover=On
ProxyPassReverse / balancer://mongrel_cluster/
<Proxy balancer://mongrel_cluster/>
BalancerMember
http://127.0.0.1:3000
BalancerMember
http://127.0.0.1:3001
BalancerMember
http://127.0.0.1:3002
BalancerMember
http://127.0.0.1:3003
</Proxy>
</VirtualHost>
/etc/rc.d/init.d/httpd restart
mysql>show variables like 'char%';