作者:Charles Brian Quinn
原文鏈接:http://mongrel./docs/apache.html
當(dāng)下最佳rails 站點部署應(yīng)該是 利用Apache 2.2.3的mod_proxy_balancer為Mongrel作負(fù)載均衡。
剛上線的站點,Mongrel雖然稍顯慢些,但也足夠支撐。先把站做好了,再考慮大流量沖擊吧。
安裝Mongrel的過程(前提已經(jīng)按好帶rubygem的ruby+rails):
gem install win32-service #在更新下來的列表里選擇最新版本安裝
gem install mongrel #選擇最新 win32版本
gem install mongrel_service
成功在cmd console中運行完以上指令后,mongrel 已經(jīng)安裝成功
mongrel 的命令使用方法:
mongrel_rails /-h #查看所有命令
mongrel_rails service::install #查看 service::install 命令的幫助說明
開始使用Mongrel:
mongrel_rails service::install -N myapp -c c:\myapp -p 4000 -e production # 表示部署一個名叫myapp的站點,它的物理路徑是c:\myapp,它的端口號是4000 ,運行在發(fā)布環(huán)境中
mongrel_rails service::start -N myapp # 啟動名叫myapp這個站點服務(wù)
mongrel_rails service::stop -N myapp # 停止名叫myapp站點服務(wù)
另外可以在windows系統(tǒng)中的服務(wù)臺中設(shè)置開機自動啟動站點服務(wù)的選項
下一步,開始設(shè)置Apache
ServerName
ServerAlias www.
ProxyPass / http://www.:8000/
ProxyPassReverse / http://www.:8000
ProxyPreserveHost on
將靜態(tài)文件的請求留給Apache來處理,因為它更擅長
ProxyPass /images !
ProxyPass /stylesheets !
#continue with other static files that should be served by apache
Alias /images /path/to/public/images
Alias /stylesheets /path/to/public/stylesheets
#continue with aliases for static content
注:未完,后邊還有多Mongrel進程服務(wù)和負(fù)載均衡等高級應(yīng)用,目前還未到那等級,到用時補上。




