Ruby on Rails and IIS on Windows 7

Here are the steps I needed to install ruby 1.8, rails 2.3, sqlserver to run our codebase on a Windows 7 platform and run it all under IIS. It should also work for any rails 2 or 3 project.  If you use rmagick or libxml-ruby then pay attention to the installing gems part for some dlls you need to install along with where to get them.

So, having tried various solutions involving fastcgi and url rewrite which I could not get to work on IIS 7.5 under Windows 7 I found . I’ve seen the people behind it on various other posts on msdn etc so there is some history of them working on IIS, fastcgi and url rewrite. In fact I think they have had a url rewrite product available for a number of years.

* Install Rails

1) Install the Web Platform Installer from
2) Add as a new feed
3) From the zoo tab select Blank Ruby on Rails Rails project and Ruby1.8 and click the install button. It will also install other dependencies.
4) When installing the blank project it will pop up and ask you where to put it along with other required details like the name. Make a note of where the project lives since we need a couple of files from it.
5) From the blank rails project we need the web.config files in the projects root and public directories.  Place these in the same place in your rails project directories.  To use Ruby1.9 we need to replace ruby.1.9.pipe in the web.config in the projects root directory with ruby.1.8.pipe. You may also have to add the path to ruby’s bin directory to your environment variables – C:\Ruby18\bin or C:\Ruby19\bin
6) Ensure that the projects directories are writeable by the IIS_IUSRS user.
7) Add the project to IIS with the project path pointing to the rails projects root directory (not public like you would with a rails project under apache).

* Install Git

This is used for version control and can be found on Install the version marked ‘Full installer for official Git for Windows 1.7.8’ or similar (version name might be different).

* Install required gems (libxml and imagemagick specific instructions)

There are various 3rd party dependencies that the gems that MethodBox requires including imagemagick (ie. rmagick) and libxml-ruby. On windows this requires a little bit of user intervention during the install process. Go to and download
Double click and go through the installer, selecting to install C and C++ header files and libraries from the additional options page
add environment variable CPATH=\path\to\imagemagick\include and LIBRARY_PATH=\path\to\imagemagick\lib

There is a high chance that the libxml-2.2.dll needed for libxml-ruby is not present in the lib folder and will pop up an error.  The dll can be found in C:\Ruby18\lib\ruby\gems\1.8\gems\libxml-ruby-2.2.0-x86-mingw32\lib\libs\  Copy the libxml, iconv and zlib dlls and put in the C:\Ruby18\bin folder.

Note: If you are not using mysql then comment any mysql gem out of the Gemfile. Otherwise the system may complain about libmysql.dll missing.  If you are using mysql you need to copy the dll from the mysql/bin folder to the ruby lib folder.

* SQL server and rails

1) Find out your SQL server details. If your SQL server instance has not been allowed through the firewall then you need to find out its details: open up the sqlserver management console (which you can install along with sqlserver express via the Web Platform Installer – I recommend this way, downloading on its own and installing does not work correctly) and look at your db details.
2) Set up a Data Source Name (DSN) for your ODBC connection.  This is not that well documented so you need to find the C:\Windows\sysWOW64 directory and start the odbcad32 programme.  Then you add a system DSN for your instance of sqlserver.
3) Set up your rails projects database.yml as normal with the following records:

adapter: sqlserver
mode: odbc
dsn: sqlserverapp-dsn (the one you created earlier)
username: user
password: secret
host: localhost (or whatever)