国产一区二区精品久久_蜜桃狠狠狠狠狠狠狠狠狠_午夜视频精品_激情都市一区二区

當前位置:首頁 > 網(wǎng)站舊欄目 > 學(xué)習(xí)園地 > 設(shè)計軟件教程 > 在Windows平臺使用Apache2.2和Mongrel運行Ruby on Rails

在Windows平臺使用Apache2.2和Mongrel運行Ruby on Rails
2010-01-14 23:30:53  作者:  來源:
一、安裝Ruby、rails、mongrel和Apache2.2
 
從rubyforge網(wǎng)站下載One-Click Ruby Install,運行安裝程序,就安裝好了ruby和rubygems。
 
運行命令:
gem install rails –y
gem install mongrel –y
gem install mongrel_service -y
安裝好了rails和mongrel
 
從Apache網(wǎng)站下載Windows版本的Apache2.2,運行安裝程序,就安裝好了Apache2.2。
 
二、把Mongrel作為Services啟動
 
mongrel_rails service::install -N depot -c d:\Rubyproject\depot -p 3000 –e production
-N指明服務(wù)名稱,-d指明rails應(yīng)用的目錄,-p是mongrel監(jiān)聽的tcp端口,-e是啟動模式為生產(chǎn)模式
 
這樣打開控制面版|管理工具|服務(wù),就可以發(fā)現(xiàn)增加了一項名為“depot”的服務(wù),就可以通過控制面版來管理服務(wù)了。如果需要命令行啟動和關(guān)閉該服務(wù),那么:
mongrel_rails service::start -N depot
mongrel_rails service::stop -N depot
 
如果需要從服務(wù)中注銷該項服務(wù),那么:
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
 
然后按如下內(nèi)容配置基于HTTP代理的負載均衡:
xml 代碼
 
  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>  
 
myCluster定義了群集中的每個mongrel應(yīng)用服務(wù)器節(jié)點。ProxyPass /images !指明該URL開始的請求不代理給Mongrel群集,而由Apache自己處理。重起Apache,然后打開瀏覽器訪問www.xxx.com,檢查配置是否正確。
 
至此,在Windows Server上面一個具備良好穩(wěn)定性和性能的Ruby on rails生產(chǎn)環(huán)境就搭建好了。
 
對于頁面輸出,還可以使用mod_deflate進行輸出內(nèi)容壓縮,以提高頁面下載速度,這個就留給大家自己配置了。

安徽新華電腦學(xué)校專業(yè)職業(yè)規(guī)劃師為你提供更多幫助【在線咨詢