A step by step guide with how and why it works, this utilizes the ROR4IISFCGI install. How to: Run Multiple Rails Apps under IIS using fast Cgi
An installer for getting RAILS running on IIS using SQL and ISAPI rewrite.
Multiple RAILS applications on a single IIS website. Documentation for those new to RAILS, but with some IIS experience. Also covers how to get a single RAILS application running on an IIS website.
Paul Nicholls has figured out how to get Rails working on IIS. Nice explanation and it’s pretty easy to do.
This more recent page relates to RAILS on Windows Server 2003
Even more recent: RubyForIIS – The purpose of the Ruby For IIS project is to create a consistent setup procedure and helper applications to make life easier when trying to get Ruby on Rails running together with the Microsoft Internet Information Server, a.k.a. IIS.
If you do use this installer, you will need to correct the placement of files. Currently the installer creates the RubyForIIS folder in your ruby install directory (c:\ruby). Copy all files and folders from \RubyForIIS to the C:\ruby\lib\ruby\site_ruby\1.8 folder.
Despite the extremely useful articles above I would like to warn anyone planning on trying the above that there are a lot of pit falls. IIS is not a first tier Rails platform and it really shows. This guide is going to gloss over setting up a database because all my databases were on separate machines. I am also going to assume that the server root directory is to be that of the Rails application.
RailsOnWindows details this. See the Ruby programming environment" and “Setting up Ruby, Ruby Gems and Rails” sections. Essentially you will need the "One Click Installer (ensure that RubyGems and OpenSSL are ticked) and gem install rails --include-dependencies .
Ensure that your application works with WEBrick on the victim machine. This step is vital because WEBrick will report more detailed errors than IIS/FastCGI will. If your app doesn’t work with WEBrick it’s definitely not going to work IIS/FastCGI.
Go to Control Panel → Administrative Tools → Internet Information Services. Press the right mouse button over Default Web Site and go to Properties. In the following dialog go to Home Directory and change it to your Rails app’s public directory.
To support the PrettyURLs rails generates we need a rewriter. I installed Ionic’s Isapi Rewrite Filter . Unpack the archive and copy IsapiRewrite4.dll,IsapiRewrite4.ini to C:\Inetpub\ . Edit IsapiRewrite4.ini so it contains the following:
RewriteRule (/[.]+)$ /dispatch.fcgi?$1
You will now need to go to IIS Control Panel and bring up the Properties on Web Sites. Browse to the ISAPI Filters tab and click Add… and as the filter name put rewrite. Use the browse button to go to C:\Inetpub\ and double click the the IsapiRewrite4.dll . Click OK. This should add rewrite to the bottom of the ISAPI filters list.
This isn’t necessary on most systems so you can skip this section… I’m not deleting it in case anyone else needs it.
I needed to edit actionpack-1.7.0\lib\action_controller\request.rb in order for routing to work correctly. The change I made was to request_uri:
def request_uri
unless env‘REQUEST_URI’.nil?
(r{\w+\://[/]+(/.*|$)$} =~ env‘REQUEST_URI’) ? $1 : env‘REQUEST_URI’ # Remove domain, which webrick puts into the request_uri.
else # REQUEST_URI is blank under IIS – get this from PATH_INFO and SCRIPT_NAME
script_filename = env“SCRIPT_NAME”.to_s.match(r{[^/]+$})
#request_uri = env“PATH_INFO”
request_uri = “"
# script_filename contains the path all the way to the script for me…
request_uri.sub!(/#{script_filename}/, ’’) unless script_filename.nil?
request_uri += env[”QUERY_STRING"] unless env“QUERY_STRING”.nil? || env“QUERY_STRING”.empty?
return request_uri
end
end
This works with Rails 0.13 and up. I’m using the free ISAPI Rewrite filter. However, the rewrite rule I use should work with other filters.
1. Add this to your environment.rb file
ActionController::Base.asset_host = ‘/myapp/’
2. Add extra routes to your routing file
Assume your routes looks like this:
map.connect ‘:controller/:action/:id’
You should change it to this
base_dir = “/myapp/”
map.connect base_dir + ‘:controller/:action/:id’map.connect ‘:controller/:action/:id’
Finally, if you’re using ISAPI Rewrite (free version), add this to your httpd.ini file:
RepeatLimit 0 RewriteRule ^(/myapp[^.]*)$ dispatch.fcgi/$1 [L]
TBC
(talk about installing FastCGI ISAPI dll, adding .fcgi mapping (possibly before url rewriting), installing RubyForIIS (including warning about mysql.so) adding FastCGI registry keys, frustrating error messages
category: Howto
Baz:
I’ve posted up my experiences with setting up IIS here: http://made-of-stone.blogspot.com/
FastCGI appears to have worked OK apart from getting the SOAP web services to work. Funeral Flowers, USA Yellow pages, dreamhost promo code, Dreamhost promo code and coupons and sympathy flowers are examples of my work. I’ve also adapted a reverse proxy that allows you to hide multiple WEBrick servers behind an IIS installation, so your boss need never know!
A step by step guide with how and why it works, this utilizes the ROR4IISFCGI install. How to: Run Multiple Rails Apps under IIS using fast Cgi
An installer for getting RAILS running on IIS using SQL and ISAPI rewrite.
Multiple RAILS applications on a single IIS website. Documentation for those new to RAILS, but with some IIS experience. Also covers how to get a single RAILS application running on an IIS website.
Paul Nicholls has figured out how to get Rails working on IIS. Nice explanation and it’s pretty easy to do.
This more recent page relates to RAILS on Windows Server 2003
Even more recent: RubyForIIS – The purpose of the Ruby For IIS project is to create a consistent setup procedure and helper applications to make life easier when trying to get Ruby on Rails running together with the Microsoft Internet Information Server, a.k.a. IIS.
If you do use this installer, you will need to correct the placement of files. Currently the installer creates the RubyForIIS folder in your ruby install directory (c:\ruby). Copy all files and folders from \RubyForIIS to the C:\ruby\lib\ruby\site_ruby\1.8 folder.
Despite the extremely useful articles above I would like to warn anyone planning on trying the above that there are a lot of pit falls. IIS is not a first tier Rails platform and it really shows. This guide is going to gloss over setting up a database because all my databases were on separate machines. I am also going to assume that the server root directory is to be that of the Rails application.
RailsOnWindows details this. See the Ruby programming environment" and “Setting up Ruby, Ruby Gems and Rails” sections. Essentially you will need the "One Click Installer (ensure that RubyGems and OpenSSL are ticked) and gem install rails --include-dependencies .
Ensure that your application works with WEBrick on the victim machine. This step is vital because WEBrick will report more detailed errors than IIS/FastCGI will. If your app doesn’t work with WEBrick it’s definitely not going to work IIS/FastCGI.
Go to Control Panel → Administrative Tools → Internet Information Services. Press the right mouse button over Default Web Site and go to Properties. In the following dialog go to Home Directory and change it to your Rails app’s public directory.
To support the PrettyURLs rails generates we need a rewriter. I installed Ionic’s Isapi Rewrite Filter . Unpack the archive and copy IsapiRewrite4.dll,IsapiRewrite4.ini to C:\Inetpub\ . Edit IsapiRewrite4.ini so it contains the following:
RewriteRule (/[.]+)$ /dispatch.fcgi?$1
You will now need to go to IIS Control Panel and bring up the Properties on Web Sites. Browse to the ISAPI Filters tab and click Add… and as the filter name put rewrite. Use the browse button to go to C:\Inetpub\ and double click the the IsapiRewrite4.dll . Click OK. This should add rewrite to the bottom of the ISAPI filters list.
This isn’t necessary on most systems so you can skip this section… I’m not deleting it in case anyone else needs it.
I needed to edit actionpack-1.7.0\lib\action_controller\request.rb in order for routing to work correctly. The change I made was to request_uri:
def request_uri
unless env‘REQUEST_URI’.nil?
(r{\w+\://[/]+(/.*|$)$} =~ env‘REQUEST_URI’) ? $1 : env‘REQUEST_URI’ # Remove domain, which webrick puts into the request_uri.
else # REQUEST_URI is blank under IIS – get this from PATH_INFO and SCRIPT_NAME
script_filename = env“SCRIPT_NAME”.to_s.match(r{[^/]+$})
#request_uri = env“PATH_INFO”
request_uri = “"
# script_filename contains the path all the way to the script for me…
request_uri.sub!(/#{script_filename}/, ’’) unless script_filename.nil?
request_uri += env[”QUERY_STRING"] unless env“QUERY_STRING”.nil? || env“QUERY_STRING”.empty?
return request_uri
end
end
This works with Rails 0.13 and up. I’m using the free ISAPI Rewrite filter. However, the rewrite rule I use should work with other filters.
1. Add this to your environment.rb file
ActionController::Base.asset_host = ‘/myapp/’
2. Add extra routes to your routing file
Assume your routes looks like this:
map.connect ‘:controller/:action/:id’
You should change it to this
base_dir = “/myapp/”
map.connect base_dir + ‘:controller/:action/:id’map.connect ‘:controller/:action/:id’
Finally, if you’re using ISAPI Rewrite (free version), add this to your httpd.ini file:
RepeatLimit 0 RewriteRule ^(/myapp[^.]*)$ dispatch.fcgi/$1 [L]
TBC
(talk about installing FastCGI ISAPI dll, adding .fcgi mapping (possibly before url rewriting), installing RubyForIIS (including warning about mysql.so) adding FastCGI registry keys, frustrating error messages
category: Howto
Baz:
I’ve posted up my experiences with setting up IIS here: http://made-of-stone.blogspot.com/
FastCGI appears to have worked OK apart from getting the SOAP web services to work. Funeral Flowers, USA Yellow pages, dreamhost promo code, Dreamhost promo code and coupons and sympathy flowers are examples of my work. I’ve also adapted a reverse proxy that allows you to hide multiple WEBrick servers behind an IIS installation, so your boss need never know!