在Windows下面用Mongrel作为Rails服务器平台

最近一直在寻找Rails在Windows平台上服务器平台,Google一番,终于发现了Mongrel这个优秀的平台。

步骤如下:

1、安装完成Rails以后,生成一个Rails程序,目录在d:\ruby\mywork\ent

2、安装Mongrel

gem install mongrel –y

gem install mongrel_service -y

安装好了rails和mongrel

3、把Mongrel作为Services启动

mongrel_rails service::install -N ent -c d:\ruby\mywork\ent -p 3000 –e production

-N指明服务名称,-d指明rails应用的目录,-p是mongrel监听的tcp端口,-e是启动模式为生产模式

在命令行里面,运行会提示安装成功。

4、打开控制面板-》管理工具-》服务里面,会找到ent这个服务名称,ent就是前面第3不输入的步骤,启动这个服务就可以,当然可以设置为自动启动(确实情况下是手工启动)

5、服务的删除和停止

mongrel_rails service::stop -N ent

如果需要从服务中注销该项服务,那么:

mongrel_rails service::remove -N ent

如果需要安装多个mongrel实例,那么可以这样:

mongrel_rails service::install -N ent0 -c d:\ruby\mywork\ent -p 3000 –e production

mongrel_rails service::install -N ent1 -c d:\ruby\mywork\ent -p 3001 –e production

6、其实现在就可以用http://localhost:3000来访问Rails程序了。

7、可以用Apache的Proxy功能,来把向本机80的请求转发到3000端口,实现Rails的发布。

配置如下在httpd.conf里面进行修改,去掉下面三行前面的注释(#):

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

如果你希望对页面输出使用压缩,也需要取消如下模块的注释:

LoadModule deflate_module modules/mod_deflate.so

最后加入:

ProxyRequests Off   

<Proxy balancer://myCluster>

  BalancerMember http://localhost:3000   

  BalancerMember http://localhost:3001   

>

 

<VirtualHost *:80>

  ServerName www.xxx.com   

  DocumentRoot d:/rubyproject/depot/public   

  ProxyPass /images !   

  ProxyPass /stylesheets !   

  ProxyPass /javascripts !   

  ProxyPass / balancer://myCluster/   

  ProxyPassReverse / balancer://myCluster/   

  ProxyPreserveHost on   

>

诸如此类。

del.icio.us 标记: rails, mongrel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值