Apache2 Mongrel-Cluster Configuration

$ wget http://apache.justdn.org/httpd/httpd-2.2.4.tar.gz
($ sudo apt-get install apache2 is NOT recommended)

$ sudo gem install mongrel –include-dependencies
$ sudo gem install mongrel_cluster –include-dependencies
$ sudo /usr/sbin/adduser -r mongrel (creating a user for mongrel running)

cd httpd-2.2.4
./configure –prefix=/etc/apache2 –enable-cache –enable-mem-cache \
–enable-deflate –enable-proxy –enable-proxy-html –enable-proxy-balancer \
–enable-rewrite –enable-headers –enable-filecache –enable-ssl \

make
make install

–Note
# Apache and mongrel could work together in two ways, single instance and cluster
# We will describe both of them as follows:

1 — single mongrel instance
–enter your application’s path
$ mongrel_rails start -d -p 8000

–enter your apache2 httpd.conf, usually /etc/apache2 , and add these scripts

<virtualhost></virtualhost>
ServerName localhost
ServerAlias http://localhost

ProxyPass / http://localhost:8000/
ProxyPass /images !
ProxyPass /stylesheets !
#continue with other static files that should be served by apache

#continue with aliases for static content

ProxyPassReverse / http://localhost:8000/
ProxyPreserveHost on
2 — mongrel cluster
$ sudo gem install daemons gem_plugin mongrel mongrel_cluster –include-dependencies
$ sudo /usr/sbin/adduser -r mongrel

$ cd /path/to/yourapps
$ sudo mongrel_rails cluster::configure -e production \
-p 8000 -N 3

[NOTE! please make sure there’re only one mongrel_cluster.yml file in your system.]

You could test now:
—————
$ sudo mongrel_rails cluster::start
$ sudo mongrel_rails cluster::stop
—————

$ sudo mkdir /etc/mongrel_cluster
$ sudo ln -s /path/to/yourapp/config/mongrel_cluster.yml \
/etc/mongrel_cluster/yourapp.yml
$ cd /etc/init.d/
$ sudo cp /usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-0.2.1/resources/mongrel_cluster mongrel_cluster
$ sudo chmod +x /etc/init.d/mongrel_cluster

make sure these configuration is uncommented in httpd.conf
NOTE, if you have these modules buit-in, you may ignore it.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

DocumentRoot /path/to/yourapp/public

Edit httpd.conf:

<proxy></proxy> BalancerMember http://localhost:8000
BalancerMember http://localhost:8001
BalancerMember http://localhost:8002<virtualhost></virtualhost>
ServerName yourapp.com
ServerAlias http://yourapp.com
ServerAdmin yourapp@yourapp.com

 

DocumentRoot “/path/to/yourapp/public”
RewriteEngine On

ProxyPass /images balancer://yourCluster/images

ProxyPass /stylesheets balancer://yourCluster/stysheets
ProxyPass /javascripts balancer://yourCluster/javascripts

ProxyPass / balancer://yourCluster/

ProxyPassReverse / balancer://yourCluster/
ProxyPreserveHost on

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值