六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 82|回复: 0

[整理] Windows 上面跑 Apache 2.2 + Mongrel

[复制链接]

升级  67.33%

41

主题

41

主题

41

主题

秀才

Rank: 2

积分
151
 楼主| 发表于 2013-2-7 03:29:46 | 显示全部楼层 |阅读模式
Windows 上面 Ruby 效能不佳,所以我曾經建議不使用 Windows 作為 Service 環境。但是如果你真的要用 Windows 作為 Server ,你可以看這一篇。

不過請注意,我在之前就講過,我沒有 Windows 可以測試,只能整理別人的文章。尤其參考最多的是 Robbin 寫的 在Windows平台使用Apache2.2和Mongrel运行Ruby on Rails,雖然沒有照著翻譯,但是你依舊可以視這篇文章為 Robbin 本文的繁體中文整理翻譯版,榮耀是歸於 Robbin 的。

[size=130%]安裝 Ruby on Rails and Mongrel
下載Windows版的Ruby來安裝,安裝時請記得裝 RubyGems。再來請用 gem 安裝下列三個套件
gem i rails mongrel mongrel_service –y
[size=130%]啟動 mongrel_service
mongrel_service 就是 Windows 上面 Win32 Service 的 plugin。我們要先將 Mongrel 登記為其中一個 Windows Service。
mongrel_rails service::install -N service_name -c c:\rails\service -p 3000 –e production


  • -N :win32 service 名字
  • -c:Rails 程式 root 目錄
  • -p:聽的 port
  • -e:Rails 環境
仔細去看Win32 的service list,你會發現出現了一個你剛剛登記的 service_name。啟動的話就是
mongrel_rails service::start -N service_name
停止就是
mongrel_rails service::stop -N service_name
取消 service 登記就是
mongrel_rails service::remove -N service_name
如果你想 Windows 啟動,自動啟動 Mongrel Service,請按下
sc config service_name start= auto
如果你想說順便一起啟動 Mongrel Service 跟 MySQL,請按下
sc config service_name start= auto dependency= MySql

[size=130%]Mongrel_cluster ?
大家一定很懷念 Mongrel Cluster 這樣的神兵利器吧,很可惜,Windows 上面沒有 Mongrel Cluster,所以大家要啟動 3000 ~ 3009 就得這樣搞
mongrel_rails service::install -N service_name1 -p 3000 –e production
mongrel_rails service::install -N service_name2  -p 3001 –e production
mongrel_rails service::install -N service_name3  -p 3002 –e production
...
mongrel_rails service::install -N service_name4  -p 3009 –e production
笨嗎?蠢嗎?所以才跟你說 Ruby on Rails 不適合用 Windows 咩。
[size=130%]安裝 Apache 2.2
去 Apache 網站下載 Apache 2.2 Windows 版本。然後在httpd.conf enable module
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
使用 config file 就如同我這個網頁寫的方式,或是直接看 Robbin 寫的也可以。


延伸閱讀
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表