Chinaunix首页 | 论坛 | 博客
  • 博客访问: 379812
  • 博文数量: 120
  • 博客积分: 5051
  • 博客等级: 大校
  • 技术积分: 1255
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-03 01:25
文章分类

全部博文(120)

文章存档

2011年(2)

2010年(11)

2009年(28)

2008年(26)

2007年(53)

我的朋友

分类: LINUX

2007-12-12 19:00:03

|

12/14/2006

本來沒有打算寫的,不過看到 ,所以還是順便寫一下好了。架設一些觀念在此我有作介紹,可以參考一下。


設定 Mongrel Cluster

請將你的 Mongrel Cluster 設定好,這裡預設 port 從 4000 ~ 4009 ,一共十個,跑在 production 環境下
mongrel_rails cluster::configure -e production -p 4000 -N 10
mongrel_rails cluster::start
修改 Apache 2.2 設定檔

Apache 的設定檔放在 httpd.conf ,以下修改內容皆在 httpd.conf 裡面設定。

首先確定你的 Apach 2.2 有 enable apache 的其中一個 Module mod_proxy
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
再來我們開始設定 Mongrel Cluster 的 reverse proxy 設定,首先我們給這組 cluster 取名叫做 examplecluster,他是10組 Mongrel ,跑在 port 4000 ~ 4009 之中

# cluster member 1
BalancerMember
BalancerMember
....
BalancerMember
再來假設你的 hostname 為 example.com,我們開始設定 virtual host

ServerName example.com
ServerAdmin root@example.com
DocumentRoot "/var/www/example.com/htdocs"
ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass / balancer://examplecluster/
ProxyPassReverse / balancer://examplecluster/


重 點是在於 ProxyPass,ProxyPass 代表 images,stylesheets,javascript 等 static file 交給 Apache 處理,不要給 Mongrel 處理。 還有 ProxyPassReverse 要指定正確的 cluster name ,我們要指定為 examplecluster。

最後重起 Apache 即可。本設定改自著名的文章 Scaling Rails with Apache 2.2, mod_proxy_balancer and Mongrel,還有 Robin 的 。設定是在 Gentoo Linux + Apache 2.2.3 + Mongrel 跑完全沒有任何問題。

 


阅读(609) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~