閔毓
          http://www.eshoo.com.cn 歡迎來到異客中國
          posts - 49,comments - 97,trackbacks - 0
          摘自:http://www.javaeye.com/topic/43290
          一、安裝Ruby、rails、mongrel和Apache2.2
          ?
          從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 代碼
          ?
          1. ProxyRequests?Off ??
          2. < Proxy ?balancer://myCluster > ??
          3. ??BalancerMember?http://localhost:3000 ??
          4. ??BalancerMember?http://localhost:3001 ??
          5. > ??
          6. ??
          7. < VirtualHost ?*:80 > ??
          8. ??ServerName?www.xxx.com ??
          9. ??DocumentRoot?d:/rubyproject/depot/public ??
          10. ??ProxyPass?/images?! ??
          11. ??ProxyPass?/stylesheets?! ??
          12. ??ProxyPass?/javascripts?! ??
          13. ??ProxyPass?/?balancer://myCluster/ ??
          14. ??ProxyPassReverse?/?balancer://myCluster/ ??
          15. ??ProxyPreserveHost?on ??
          16. > ??
          ?
          myCluster定義了群集中的每個mongrel應用服務器節點。ProxyPass /images !指明該URL開始的請求不代理給Mongrel群集,而由Apache自己處理。重起Apache,然后打開瀏覽器訪問www.xxx.com,檢查配置是否正確。
          ?
          至此,在Windows Server上面一個具備良好穩定性和性能的Ruby on rails生產環境就搭建好了。
          ?
          對于頁面輸出,還可以使用mod_deflate進行輸出內容壓縮,以提高頁面下載速度,這個就留給大家自己配置了。


          關閉標記被Rich Editor過濾掉了,重新用bbcode貼一下:

          代碼
          1. ProxyRequests?Off???? ??
          2. <Proxy?balancer://myCluster>??? ??
          3. ??BalancerMember?http://localhost:3000???? ??
          4. ??BalancerMember?http://localhost:3001???? ??
          5. </Proxy>??? ??
          6. ??? ??
          7. <VirtualHost?*:80>??? ??
          8. ??ServerName?www.xxx.com???? ??
          9. ??DocumentRoot?d:/rubyproject/depot/public???? ??
          10. ??ProxyPass?/images?!???? ??
          11. ??ProxyPass?/stylesheets?!???? ??
          12. ??ProxyPass?/javascripts?!???? ??
          13. ??ProxyPass?/?balancer://myCluster/???? ??
          14. ??ProxyPassReverse?/?balancer://myCluster/???? ??
          15. ??ProxyPreserveHost?on???? ??
          16. </VirtualHost>????

          cluster的作用不是加速單個請求的,是提高整體的負載能力的。

          posted on 2007-01-15 13:23 閔毓 閱讀(959) 評論(0)  編輯  收藏 所屬分類: 其他
          主站蜘蛛池模板: 柏乡县| 鹤峰县| 井研县| 潼南县| 石阡县| 留坝县| 和平区| 双江| 珲春市| 绥棱县| 抚远县| 满洲里市| 巴彦淖尔市| 明溪县| 城市| 横山县| 临颍县| 达拉特旗| 德令哈市| 沈丘县| 德格县| 扎兰屯市| 台江县| 白山市| 东阿县| 卢龙县| 光泽县| 毕节市| 高台县| 天镇县| 辽阳市| 海门市| 阜阳市| 英山县| 监利县| 蚌埠市| 文水县| 依兰县| 斗六市| 兴海县| 革吉县|