?
從rubyforge網站下載One-Click Ruby Install,運行安裝程序,就安裝好了ruby和rubygems。
?
運行命令:
gem install rails –y
gem install mongrel –y
gem install mongrel_service -y
安裝好了rails和mongrel
?
從Apache網站下載Windows版本的Apache2.2,運行安裝程序,就安裝好了Apache2.2。
?
二、把Mongrel作為Services啟動
?
mongrel_rails service::install -N depot -c d:\Rubyproject\depot -p 3000 –e production
-N指明服務名稱,-d指明rails應用的目錄,-p是mongrel監聽的tcp端口,-e是啟動模式為生產模式
?
這樣打開控制面版|管理工具|服務,就可以發現增加了一項名為“depot”的服務,就可以通過控制面版來管理服務了。如果需要命令行啟動和關閉該服務,那么:
mongrel_rails service::start -N depot
mongrel_rails service::stop -N depot
?
如果需要從服務中注銷該項服務,那么:
mongrel_rails service::remove -N depot
?
如果需要安裝多個mongrel實例,那么可以這樣:
mongrel_rails service::install -N depot0 -c d:\Rubyproject\depot -p 3000 –e production
mongrel_rails service::install -N depot1 -c d:\Rubyproject\depot -p 3001 –e production
諸如此類。
?
三、配置Apache2.2
?
用編輯工具打開Apache2.2目錄下面的conf/httpd.conf,需要取消如下模塊的注釋:
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
如果你希望對頁面輸出使用壓縮,也需要取消如下模塊的注釋:
LoadModule deflate_module modules/mod_deflate.so
?
然后按如下內容配置基于HTTP代理的負載均衡:
xml 代碼
?
-
ProxyRequests?Off ??
-
<
Proxy
?balancer://myCluster
>
??
-
??BalancerMember?http://localhost:3000 ??
-
??BalancerMember?http://localhost:3001 ??
-
>
??
-
??
-
<
VirtualHost
?*:80
>
??
-
??ServerName?www.xxx.com ??
-
??DocumentRoot?d:/rubyproject/depot/public ??
-
??ProxyPass?/images?! ??
-
??ProxyPass?/stylesheets?! ??
-
??ProxyPass?/javascripts?! ??
-
??ProxyPass?/?balancer://myCluster/ ??
-
??ProxyPassReverse?/?balancer://myCluster/ ??
-
??ProxyPreserveHost?on ??
-
>
??
?
myCluster定義了群集中的每個mongrel應用服務器節點。ProxyPass /images !指明該URL開始的請求不代理給Mongrel群集,而由Apache自己處理。重起Apache,然后打開瀏覽器訪問
www.xxx.com,檢查配置是否正確。
?
至此,在Windows Server上面一個具備良好穩定性和性能的Ruby on rails生產環境就搭建好了。
?
對于頁面輸出,還可以使用mod_deflate進行輸出內容壓縮,以提高頁面下載速度,這個就留給大家自己配置了。
關閉標記被Rich Editor過濾掉了,重新用bbcode貼一下:
代碼
- ProxyRequests?Off???? ??
- <Proxy?balancer://myCluster>??? ??
- ??BalancerMember?http://localhost:3000???? ??
- ??BalancerMember?http://localhost:3001???? ??
- </Proxy>??? ??
- ??? ??
- <VirtualHost?*:80>??? ??
- ??ServerName?www.xxx.com???? ??
- ??DocumentRoot?d:/rubyproject/depot/public???? ??
- ??ProxyPass?/images?!???? ??
- ??ProxyPass?/stylesheets?!???? ??
- ??ProxyPass?/javascripts?!???? ??
- ??ProxyPass?/?balancer://myCluster/???? ??
- ??ProxyPassReverse?/?balancer://myCluster/???? ??
- ??ProxyPreserveHost?on???? ??
- </VirtualHost>????
cluster的作用不是加速單個請求的,是提高整體的負載能力的。
posted on 2007-01-15 13:23
閔毓 閱讀(955)
評論(0) 編輯 收藏 所屬分類:
其他