Windows XP, Apache 2 and SCGI Quick Start

These are my notes so I remember what I did in the future. Maybe they’ll work for you too. Consider the starting point a working system with XP, Apache2, FastCGI, etc. and the required gems/libs.These are the steps that worked for me.

The various pieces:

  1. SCGI Rails 0.4.2

Apache2 configuration

Unzip and place the in
your Apache’s modules dir.


Add the line:

LoadModule scgi_module modules/

where all the rest of the LoadModules are.

I use virtual hosts so I can run multiple Rail apps in the same
Apache. Here’s how I configured one of them for SCGI:

<VirtualHost *>
  ServerName foo
  DocumentRoot /www/foo/public
  SCGIMount /
  <LocationMatch ..+$>
    # don’t handle those with SCGI
    SCGIHandler Off
  <Directory /www/foo/public/>
    Options ExecCGI FollowSymLinks
    AllowOverride all
    Allow from all
    Order allow,deny

That’s pretty much it for Apache.

Rail app configuration


You can change things if you want but guess what? It doesn’t really
matter. There’s some nice Ruby magic involved. For completeness, I
added a couple of lines just so I’d remember….

AddHandler scgi-script .scgi
RewriteRule ^(.*)$ dispatch.scgi [QSA,L]

SCGI config

The gem installed a few things for you. Change to your Rail app dir
and do the following to configure your app using the SCGI utils.


scgi_ctrl config -e development -S

and enter a password. Password is used by the monitoring & config
changing tools.

The -e determines what environment to use, the standards apply:
development, production, etc.

The -S is very important for Windows users: turns off some stuff that
doesn’t work and will prevent SCGI from running.

The config file that scgi_ctrl creates in RAILS_APP/config is called

Here’s mine:

:logfile: log/scgi.log
:config: config/scgi.yaml
:disable_signals: true
:env: development
:control_url: druby://
:password: xxxxxxxx
:port: 9999

Pretty much the defaults. Notice how the :port here matches the
SCGIMount directive in your httpd.conf from above.

Making it go

Now that you’re all configured, run:


right there in your Rail app dir.

You shouldn’t see anything happen. Not until you get Apache going and
start hitting some pages. So do that now.

There are some log files you’ll want to look at to verify things.

In your Apache2 log dir, look for something like this in your

[Sat Oct 22 09:01:35 2005] [notice] Apache/2.0.55 (Win32) mod_fastcgi/2.4.2 mod_scgi/1.7 configured — resuming normal operations

Should see a mod_scgi entry.

In RAILS_APP/log look at the scgi.log. You should see something like

==> scgi.log <==
[INF][7716] POSIX signal control disabled.
[INF][7716] Running in development mode on

If you’re seeing those log entries, everything should be
working…. Fingers crossed!

If things aren’t working, double check everything’s cool with
Apache. Test the config, make sure it can find what it needs. Most of
my issues (and the reason for this little howto) stemmed from trying
to figure out which of the various combinations of SCGI utils & config
files did the right thing.

So thanks to Zed Shaw, Curt Hibbs and the others for making my Rails
apps faster and less troublesome.

This entry was posted in Uncategorized and tagged . Bookmark the permalink. Both comments and trackbacks are currently closed.