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.
Step 1: INSTAL IIS AND CGI
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
- REQUIRED: CGI. This is the same as the FastCGI support
- REQUIRED: IIS Management Console
- OPTIONAL: Custom HTTP Features: Static Content, etc
[We will use this to check if IIS is installed correctly]
- OPTIONAL : Other health and diagnostics info as
Shows in the picture below
Click OK and let the Windows install IIS and FastCGI for you.
Step 2: VERIFY THAT IIS IS WORKING
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.
Step 3: INSTALL RUBY
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!
Step 4: VERIFY RUBY IS IN THE PATH
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.
Step 5: INSTALL RAILS
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.
*** LOCAL GEMS ***
rake (0.8.7, 0.8.1)
win32-api (1.2.1, 1.2.0)
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.
The website should start.
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.
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
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
render :text=>"The index action"
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.
<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
http://blog.anlek.com/2008/09/installing-updating-sqlite3-on-windows/ 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