在Windows平台使用LightTPD和Mongrel运行Ruby on Rails

什么是Mongrel?

一个快速的Web Server,速度快于WEBrick甚多,网络上的介绍很多。

什么是Lighttpd?

用于转发request到a cluster of Mongrel,网络上的介绍同样很多。

使用它们可以解决Rails在request上面出现的问题。

一、首先从rubyforge网站下载One-Click Ruby Install,运行安装程序,就安装好了ruby和rubygems。
运行命令:
gem install rails –y
gem install mongrel –y
gem install mongrel_service -y
安装好了rails和mongrel,注意安装mongrel和montrel_service时选择for windows。

二、把Mongrel作为Services启动
mongrel_rails service::install -N depot -c d:\Rubyproject\depot -p 3000 –e production
-N指明服务名称,-c指明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
诸如此类。

三、安装和配置LightTPD
首先下载lighttpd for windows,这个地址是我从网络找到的http://blog.621000.net/download.php?id=627,还有一个WLMP包,这一个整合包,方便普通用户,
包括以下软件:
LightTPD 1.4.15
MySQL 5.0.44
PHP 5.2.3
MiniPerl 5.8.8
OpenSSL 0.9.8e
phpMyAdmin 2.10.2

windows版本的lighttpd默认被安装在c:/lighttpd,这个安装位置是不能修改的

配置Lighttpd,配置port:

打开c:\lighttpd\conf\lighttpd-inc.conf

取消 server.port = 81 前的注释,你也可以使用port:80

开启模块,其他模块不要乱开,会出问题

server.modules = ("mod_proxy",
"mod_rewrite",
"mod_accesslog",
"mod_alias" )

另外在这个配置文件末位加上:

proxy.debug = 0
proxy.balance = "fair"
proxy.server = ( "/" =>
(
( "host" => "127.0.0.1", "port" => 3000)
)
)

这里的port就是Mongrel server的port,启动Lighttpd使用命令:

c:\lighttpd\lighttpd.exe -f conf\lighttpd-inc.conf -m lib

也可以直接运行c:\lighttpd\Start-LightTPD.bat

通过http://localhost:81/depot 或http://(服务器的IP地址或完整的计算机名称):81/depot就可以成功访问
使用计算机名时,要在C:\WINDOWS\system32\drivers\etc\hosts文件中增加: 服务器IP地址 服务器计算机名称,如:192.168.0.1 depot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值