Ruby On Rails with IIS 7 - Reloaded

Ruby On Rails with IIS 7 - Reloaded

  • Comments 28

In my last post I mentioned getting into Ruby and making MABUILD and rake work together.
I think I found a better way to do the same with PowerShell integration, which I will
write up sometime this week.

Now, it is inevitable that Ruby leads to Ruby On Rails. I needed to get RoR work on my dev machine with VISTA SP1 and IIS7.
I was little surprised to find that there are very few articles on this. A few I found were outdated. Then I landed on Ruslan's post.
It got me to a point but then I was stuck. So I walked to Ruslan's office and we discussed this quite a bit. I went back to my office and researched this some more.
I finally got this working after about 3 days of stumbling around. So here is the post that builds on Ruslan's
post and clarifies a few things. Mostly I wanted to make sure that even folks like me, who are beginners in the Ruby universe,
could follow the steps to get RoR and IIS 7 working.

I am starting here with a clean system with VISTA SP1.


Go to control panel, Programs and Features and then select "Turn features on or off". You can get there quicker
by typing appwiz.cpl on a command prompt and then selecting "Turn features on or off " from the left side

From the features select World Wide Web Services
and make sure that you select the following

  1. REQUIRED: CGI. This is the same as the FastCGI support
  2. REQUIRED: IIS Management Console
  3. OPTIONAL: Custom HTTP Features: Static Content, etc
    [We will use this to check if IIS is installed correctly]
  4. OPTIONAL : Other health and diagnostics info as
    Shows in the picture below


Click OK and let the Windows install IIS and FastCGI for you.


Once installed you can verify that the IIS is installed by going to the

Please note: If you did not enable STATIC CONTENT feature when you installed, you will get a 404 NOT FOUND.
You see the file right there but you still get 404 NOT FOUND. Security aside, it would be great
if there is a more easier way to diagnose this, I ended up researching this for more than 3 hours wondering
why am I getting the 404 not found. Anyway, now you know and you don't need to waste those hours.
Again, enable the static content feature to be able to see this static content page.



Navigate to Ruby 1.8.6 One-Click Installer and install RUBY
CAUTION: DONT INSTALL TO A FOLDER that has SPACES in the name or its path.  like "C:\program Files\Ruby"
I had strange errors and I had to reinstall RUBY. It is best to stick with the C:\Ruby.

As a side and tangential note, what's up with installing to C:\Ruby? Aren't the people in that
alternate universe hate installing to root directories like C:\? Why can't it default to C:\Program Files\Ruby?
RUBY is supposed to make you HAPPY!! Huh!



RUBY Installation should have added the C:\ruby\bin [or whatever the path you gave] to the path.
Open a command prompt; type "SET PATH" and look at the path. You should see the ruby\bin in the path.
If not, no big deal, add ruby to the path in the System Variables.
Type ruby -help to see that you get some help on the screen. This verifies that Ruby is indeed installed.



on a command prompt, type "Gem Install Rails". [The dependencies are already
included, contrary to popular belief that suggests the -includedependencies option
is required to do so]
Once installed, do "gem list" to list the gems locally installed. You should see
something like this - which should include rails.

C:\Windows\system32>gem list

*** LOCAL GEMS ***

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
fxri (0.3.6)
fxruby (1.6.16)
hpricot (0.6.164)
log4r (1.0.5)
ptools (1.1.6)
rails (2.3.2)
rake (0.8.7, 0.8.1)
ruby-opengl (0.60.0)
test-unit (2.0.1)
win32-api (1.2.1, 1.2.0)
win32-clipboard (0.4.4)
win32-dir (0.3.2)
win32-eventlog (0.5.0)
win32-file (0.5.5)
win32-file-stat (1.3.1)
win32-process (0.5.9)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.2.4)
windows-pr (0.9.3)

Step 6: Install FASTCGI Update for IIS7

I am not quite sure if this is a general update for FastCGI or just for PHP. To avoid hitting my head against a wall, I installed this anyway.

Step 7: Pretend that you are hosting a website called  RoRIIS7

Add a HOST Entry so that the name resolver won't go out to the DNS Server.
Don't forget to use an administrative command prompt from which you
launch notepad. edit Windows\System32\Driver\Etc\Hosts like below.

Step 8  Add a new Website to IIS

Go to C:\InetPub [or where ever you installed the inetpub to]

create a directory called RoRIIS7. We are not touching the wwwroot directory for this experiment.
i will post an update dealing with default web site later.

Open MMC, Add the Internet Services Manager to the MMC Console.
Expand the IIS Manager. It will show the local web server.
Click on Add WebSite to add a website like below

Here we are adding a new WebSite RoRIIS7
mapped to the physical directory C:\Inetpub\RoRIIS7
Please note that the HostName we are using RoRIIS7
AND that I am using port 8080

The website should start.

Step 9 Verify that the new website is working
To verify that the website is working, copy the IISSTART.HTM and the
welcome.png files into the RoRIIS7 directory.
Then navigate to http://RoRIIS7/iisstart.htm
You should see a page similar to step 2.
Step 10 Generate a RAILS APP
NOTE: When you generate the Rails app, make sure that
you use -D option. -D option generated the dispatchers
for CGI and FastCGI
Luanch CMD prompt as administrator
cd C:\inetpub\RoRIIS7
rails -D MyApp
cd MyApp
ruby script\generate Controller Test Index


Step 11 Generate a RAILS APP

Modify the app\controllers\test_controller.rb like below
This will enable it to display some test when we navigate to this URL

class TestController < ApplicationController
   def index
      render :text=>"The index action"
   def about
      render :text=>"The about action"

Step 12 Hook up IIS to Ruby

So far, we have IIS Setup and a Ruby App Setup
We need to hook them together now.

Go to the MMC/Internet Services Manager, Go to the site RoRIIS7 in the
MMC snapin. We are now going to add a module mapping


We are mapping * ==> All requests To the FastCGI Module.
The executable we use is of course the ruby interpreter.
But then there you see a PIPE character and the path to the
dispatch.fcgi. The reason is that Ruby by iteself does not handle
the FCGI. The FCGI handling is provided by the Rails

Once you add the mapping go to
C:\windows\system32\inetsrv\config and open
In this config file you should see a section for fast cgi

    <application fullPath="C:\ruby\bin\ruby.exe" arguments="C:\inetpub\RoRIIS7\MyApp\public\dispatch.fcgi" />

and another section for
the module mapping.

<location path="RoRIIS7">
            <add name="RubyFastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\ruby\bin\ruby.exe|C:\inetpub\RoRIIS7\MyApp\public\dispatch.fcgi" resourceType="Unspecified" />

These sections are created for you when you added the module mapping
through the GUI above. Now, you could directly edit the file yourself if you wanted to.

Sensing the smell of completion you go to http://roriis7/test/about
but then you are greeted by the

Step 13 Fixing Permissions

When working with IIS, I always turn on the security audit.
Turning the security audit on can it self be somewhat of a challenge.
Without going into detail, what is required apparently is to
grant NETWORK Service Account permissions to the RoRIIS7 Folder.
Since Ruby will write some logfiles etc to that dir. You could
possibly fine tune this later if you needed to.

Do an IISRESET and go visit http://roriis7:8080/test/about
OOPS! What went wrong now?
Apparently the RAILS needs SQLITE and it is not happy that it can't find SQLLite

Step 14 Installing SQLITE and the SQLLITE GEM

Download SQLITE-3.6.15 ZIP file and place the exe in the Ruby\Bin directory
this is the command line config  tool

Download SQLITEDLL-3.6.15 ZIP and place the dll in the system32 directory.
This is the engine for SQLITE.

Now we need to install the GEM has the
tip on getting this done

gem install --version 1.2.3 sqlite3-ruby

Step 14 COMPLETE!!!

Now you navigate to http://roriis7:8080/test/about

and you should see


There you go ladies and gentlemen, I give you Ruby On Rails with IIS7

Leave a Comment
  • Please add 2 and 8 and type the answer here:
  • Post
  • Hi,

    I was wondering if there's any reason why this would not work on Server 2008?  I followed all the steps to a T, but can't get past the 500.0 error message.  I've double and triple checked all the permissions, but no change.  Any help, or troubleshooting steps you may be able to provide would help.


    -Steve H.

  • If you're wanting an setup on Windows for development, check out BitNami stacks - they've got a Ruby one - - and a JRuby one -

    I've not had any issues with it yet. But I'm not sure if it's suitable for production environments or not.


     >>> Thanks Daf. I do have the dev environment. I am looking for
    deployment via IIS

  • I had to add the IIS_USRS group to the RoRIIS7 dir and give full control to get the 500 error to go away.

  • I also had to uncomment out this line in the environment.rb:

    <pre>config.gem "sqlite3-ruby", :lib => "sqlite3"</pre>

  • Hi,

    I'm using server 2008, and have also followed the instructions to the letter.

    I am also stuck on the http 500 error.

    I have set the netowrk permissions, and also (as a test) allowed the "everyone" group full access to c:\ruby\ and c:\inetpub\roriis7.  (this was just a test to see if it was permissions related - no joy).

    Do you have any hints as to how I can debug this?



  • I am also stuck on the http 500 error using Server 2008 x64, has anybody solved this ?

  • I am installing redMine (RoR based ticketing system) with this guide and it works great.

    however, there is still a small problem with this configuration. In redmine , if there is a new row of data created (regardless is new issue , new follow-up , new tracker or etc) .

    After record create, redMine will redirect to show the record. It will show the 500 error  at first. If I refresh it , it will load the page correctly.  It seems like IIS could not find the new record  when it is created , but later it will work. I suspect is the caching problem of dispatch.fcgi or URL Rewrite  or Module Handler setting .

    Anybody encounter this problem , any solution ?

    IIS7 + RoR 2.2.2 (RedMine) + URL Rewrite 1.1

  • Hi

    I'm using server 2008 and your simple example is running fine. The problem comes when expanding the site to handle images and css. None of the files will be forwarded. Rails log errors like "ActionController::RoutingError (No route matches "/stylesheets/main.css" with {:method=>:get}):


    You build your post on Ruslan's post about URL rewriter.

    but it's not used in your example?

    Is Ruslan's proposed solution for displaying static files the way to go to get it working?

  • To get it working with regular rails view helpers like <%= stylesheet_link_tag 'main' %>, <%= javascript_include_tag :defaults %>

    and normal tags like <img src="images/pict.gif">

    that all works well running the application on webrick.

    I added the URL revrite feature to my IIS7 site, imported the rules from Ruslan's solution, and changed the C:\windows\system32\inetsrv\config and open

    applicationhost.config handler section path"*" to path="dispatch.fcgi"

    Finally I added virtual directories to my site having alias images,stylesheets and javascripts.

  • I've followed all the instructions and am on Windows 2008. Has anyone solved this error:

    HTTP Error 500.0 - Internal Server Error

    c:\ruby\bin\ruby.exe - The FastCGI process exited unexpectedly

  • Be sure you give the following permissions:

    <Ruby> NETWORK SERVICE(Read and Execute)

    <Ruby App> NETWORK SERVICE(Read and Execute)

    <Ruby App/log> NETWORK SERVICE(Full Control)

    <Ruby App/temp> NETWORK SERVICE(Full Control)

    One last note: Account is "NETWORK SERVICE", not "NETWORK"

  • I have the same problem with c:\ruby\bin\ruby.exe - The FastCGI process exited unexpectedly

    I set permission both to ruby and my ruby site folders. =(((

  • Me Too. Premissions set and still getting error. I even tried using the latest FastCGI Update as well and it didn't work either.

  • Yep same problem here Win Server 2008 x64, permissions all triple checked, and still get the blasted 500 error.  Anyone out there solved this on x64?

  • Wow...should have paid closer attention to the rest of the comments....

    September 06, 2009 11:35 AM by Steve H.  posted the correct answer to the 500 error.  Adding permissions for IIS_IUSR group to appfolder and ruby folder cleared this error right up...good job Steve!

Page 1 of 2 (28 items) 12