Apache/SCGI on Windows XP / 2003

I ran down the rabbit hole for all of the following configurations :

  • Cygwin/lighttpd SCGI/FastCGI: compiling errors on both my dev machine and vmware test.
  • InstantRails / SCGI : well, after figuring out how to run production-mode scgi_server as a windows service (details below), I still have trouble getting InstantRails to run as a “service” itself. This is not the fault of InstantRails, and Curt, you get KUDOS KUDOS KUDOS for the work in gettting InstantRails to work at all! (see below for some details on how to auotmate the scgi-as-a-service installation, when you get InstantRails running as a service itself (or at least the apache/mysql servers).
  • IIS / FastCGI : 404 error every time. With no log output, there’s nothign to see and nothing to do.. except look elsewhere for a solution!

Here’s the final solution :

  1. Assuming your’e doing this on a virgin server : install ruby and rails and your rails app.. .test on webrick.
  2. Install Apache 2 (follow the directions, etc.)… test it for basic functionality “You were expecting your site but you got this page instead”.
  3. Go to Zed Shaw’s SCGI Rails Runner Howto site.
  4. Get the scgi gem and install it.
  5. Get the mod_scgi binary and copy to /modules (that link is assuming Apache 2… Zed has Apache 1 on the site as well.
  6. Configure /conf/httpd.conf according to the howto. This includes a LoadModule line and a configuration.
  7. Get srvany.exe kit from vbRad. Expand it to a simple location like C:srvanykit.
  8. Run C:srvanykitinstsrvw.exe. Follow the wizard. The PATH TO THE APPLICATION.EXE IS : C:srvanykitsrvany.exe. THIS IS REQUIRED. You will configure the actual path to scgi_server in a minute.
  9. Run regedit. Find the key for your service at :
  10. Add a new key : /Parameters
  11. Add a new string value : Parameters/Application.
    Value = (path-to-ruby) (path-to-scgi_server)
    Ie “C:rubybinruby.exe C:rubybinscgi_server”
  12. Add a new string value : Parameters/AppDirectory.
    Value = (path-to-rails-app-root)
    Ie “D:rails_appscookbook”
  13. Open Service control panel (Start -> Control Panel -> Adminstrative Tools -> Services). Find your service. Start it… should be running!
  14. Test the rails app: Go to http://localhost.
  15. If you have a routes issue it needs to be addressed now.

I’ll edit this post with updates as they are necessary.