views:

8824

answers:

4

I'm trying to get started writing some Ruby on Rails apps and have been successful with Mongrel but, I'd like to deploy my apps to my Apache 2.2 instance on Windows? All the tutorials I've found seem out of date and are for older versions of Apache/Rails.

Does anyone know of a good, current tutorial for configuring Apache 2.2 for Ruby on Rails apps?

A: 

I would suggest using Phusion Passenger for Rails within Apache.

http://www.modrails.com/index.html

Documentation with install details is available at: http://www.modrails.com/documentation/Users%20guide.html

Update: Didn't read the question closely enough, missed the windows part. Sorry!

danivovich
I tried Phusion Passenger this weekend and discovered it was only for Linux. Is there a Windows version?
Owen
No there is not.
Dave Nolan
+8  A: 

EDIT: At least until there's a Phusion Passenger for Win, Apache + Mongrel is the way to go. You can use Apache + FastCGI without Mongrel, but under real loads you will get (more) zombie processes and (more) memory leaks.

You could also look at proxying to Thin in the same way as detailed below. However, I've had some instabilities with Thin on Win, even though it's appreciably quicker. AB (Apache Benchmark) is your friend here!

Configuring Apache + Mongrel on Windows is not significantly different from *nix.

Essentially, you need to proxy requests coming into Apache to Mongrel. What this boils down to is something like this:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost localhost:80>
    ServerName www.myapp.comm
    DocumentRoot "C:/web/myapp/public"
    ProxyPass / http://www.myapp.com:3000/
    ProxyPassReverse / http://www.myapp.com:3000/
    ProxyPreserveHost On
</VirtualHost>

Stick this in your httpd.conf (or httpd-vhost.conf if you're including it).

It assumes you're going to run mongrel on port 3000, your Rails root is in C:\web\myapp, and you'll access the app at www.myapp.com.

To run the rails app in production mode:

mongrel_rails start -p 3000 -e production

And away you go (actually mongrel defaults to port 3000 so you could skip -p 3000 if you want).

The main difference is that you cannot daemonize mongrel on Windows (i.e. make it run in the background). Instead you can install it as a service using the mongrel_service gem.

Also, running a cluster is more complicated and you won't be able to use Capistrano. Let me know if you want more info.

Dave Nolan
Is this how Ruby on Rails apps are normally deployed on Apache? I thought that there would be away to deploy them straight to Apache without needing Mongrel.
Owen
I think it's absoutely the way - at least until there's a Phusion Passenger for Win. You can use Apache + FastCGI without Mongrel, but under real loads you will get (more) zombie processes and (more) memory leaks.
Dave Nolan
You could also look at proxying to Thin (http://code.macournoyer.com/thin/) in the same way. However, I've had some instabilities with Thin on Win, even though it's appreciably quicker. AB (apache benchmark) is your friend here!
Dave Nolan
Cool - I'll try this tonight when I get home.
Owen
Big help, thanks!
Michael Haren
+1  A: 

I'm new to RoR and have been attempting the same thing on Windows Server 2008, here are some additional notes on getting mongrel going as a service:

if you get compilation errors when installing mongrel_service:

gem install mongrel_service

try using a binary instead by specifying your platform:

gem install mongrel_service --platform x86-mswin32

Additionally, to actually install the service you need to run this command in your RoR's app directory:

mongrel_rails service::install --name MyApp -e production -p 3001 -a 0.0.0.0

(or to remove:

mongrel_rails service::remove --name MyApp

)

Then you should be able to start/stop the app "MyApp" in your windows services control panel.

Hope that helps someone.

danny
A: 

At the moment Mongrel does not work properly with Ruby 1.9 and will throw a "msvcrt-ruby18.dll not found" error when executing the command mongrel_rails.

Thin in this case seems to be the only option for now.

muloka