作者:Charles Brian Quinn
原文鏈接:http://mongrel./docs/apache.html
當(dāng)下最佳rails 站點(diǎn)部署應(yīng)該是 利用Apache 2.2.3的mod_proxy_balancer為Mongrel作負(fù)載均衡。
剛上線的站點(diǎn),Mongrel雖然稍顯慢些,但也足夠支撐。先把站做好了,再考慮大流量沖擊吧。
安裝Mongrel的過程(前提已經(jīng)按好帶rubygem的ruby+rails):
gem install win32-service #在更新下來的列表里選擇最新版本安裝
gem install mongrel #選擇最新 win32版本
gem install mongrel_service
成功在cmd console中運(yùn)行完以上指令后,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 # 表示部署一個(gè)名叫myapp的站點(diǎn),它的物理路徑是c:\myapp,它的端口號(hào)是4000 ,運(yùn)行在發(fā)布環(huán)境中
mongrel_rails service::start -N myapp # 啟動(dòng)名叫myapp這個(gè)站點(diǎn)服務(wù)
mongrel_rails service::stop -N myapp # 停止名叫myapp站點(diǎn)服務(wù)
另外可以在windows系統(tǒng)中的服務(wù)臺(tái)中設(shè)置開機(jī)自動(dòng)啟動(dòng)站點(diǎn)服務(wù)的選項(xiàng)
下一步,開始設(shè)置Apache
ServerName
ServerAlias www.
ProxyPass / http://www.:8000/
ProxyPassReverse / http://www.:8000
ProxyPreserveHost on
將靜態(tài)文件的請(qǐng)求留給Apache來處理,因?yàn)樗瞄L
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進(jìn)程服務(wù)和負(fù)載均衡等高級(jí)應(yīng)用,目前還未到那等級(jí),到用時(shí)補(bǔ)上。