rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 应用技术 » Web服务器

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

[安装RoR:可以直接安装一步到位的Instans Rails;

                   或者:

                    下载安装Ruby<ruby-lang.org>,下载安装Rails和Rails依赖包(ActionSupport、ActionRecord、ActionMailer、ActionWebService、ActionPack、Rake。注意:最好先查看Rails的发布日志中需要的各依赖包的版本。当然,如果网速Ok的话,直接gem install rails -y就不用你辛苦下了,不过呢,自己下,自己安装,总比较明白点)<rubyForge.org>]

默认的RoR服务器是WEBrick,改~~~看下面

[来自:http://hi.baidu.com/magiclin/blog/item/116596a82c8bcbb5cb130c3a.html]

什么是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),
( "host" => "127.0.0.1", "port" => 3001 ) )

这里的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就可以成功访问

顶一下
(0)
踩一下
(0)