Ruby on Rails on IIS7

Published Jun 25 2008 by oli
I recently decided I would check out this Ruby on Rails... but I like working with Windows and IIS, so here's a step-by-step guide to get Ruby on Rails running on IIS7 with FastCGI. Optionally, you can also read the Appendix A that will show you how to get the platform and ActiveRecord running with SQL Server.

Assumptions

This guide assumes that you are running either Windows 2008 or Windows Vista SP1 or above (because Vista SP1 ships with FastCGI).

Enabling FastCGI

Windows 2008

Add CGI role service by going to Server Manager > Roles > Add Role Services. This enables both CGI and FastCGI services.

Enabling FastCGI on Windows 2008

Windows Vista SP1

Add CGI feature by going to Control Panel > Programs and Features > Turn Windows features on or off. From there check the entry Internet Information Services > World Wide Web Services > Application Development Features > CGI, then click OK. This enables both CGI and FastCGI services.

Enabling FastCGI on Windows Vista SP1

Ruby Installation

Download and install Ruby for Windows. Make sure the gem package manager is selected during the installation proces!

Rails Installation

Open a new command line window, and run the gem installer:

> gem install rails --include-dependencies

Installings Rails via Gem

RubyForIIS Installation

Download and install RubyForIIS. This package contains the required FastCGI client library for RoR in order to use dispatch.fcgi. The installation process will ask you for the Ruby Directory; make sure you specify the folder where you installed Ruby (C:\Ruby by default).

Creating a sample application

Open a new command line window and type:

>rails testapp
>cd testapp
>rails script\generate controller index

Open Internet Services Manager (Start > Run > inetmgr), and create a new site.
Click on your site > Handler Mappings  Add Module Mapping:

  • Request path: * (asterisk)
  • Module: FastCgiModule
  • Executable: c:\ruby\bin\ruby.exe|c:\inetpub\wwwroot\testapp\public\dispatch.fcgi development
  • Name: rails-testapp

Click OK. When prompted to create a FastCGI application for this executable, click Yes.


Adding Module Mapping in IIS7

Appendix A: Adding SQL Server Support

Starting with Rails 2.0 the ActiveRecord sqlserver adapter is no longer included by default and must be installed separately:

>gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org

Get the latest source distribution of Ruby-DBI from: http://rubyforge.org/projects/ruby-dbi/ and copy the file:

lib/dbd/ADO.rb

to

C:/ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb

Then in the config/database.yml  of your application:

development:
  adapter: sqlserver
  database: database_name
  host: server_name
  username: user_name
  password: your_pw_here

And that should be it!

Copyright 2008 Wifidelity Inc. | 1-866-647-WIFI (9434)