Re: A Nightmare on Rails Street: Windows Lives!

Justin Forder
2005-03-07T04:02:51Z

Sascha Ebach wrote:

> Hi John,
>
> I have never managed to get Rails working on my Windows XP box.
> Something always fails. But I managed to install Colinux/Debian
> (www.colinux.org) with lighttpd/fastcgi which is considerably faster
> than Cygwin. So you might want to investigate. It is a little bit like
> cheating. But it is so nice to have a real OS running as a service in
> Windows. The way I see it, it is the best solution for deploying on
> Windows. Cygwin is good for many things, but when it gets serious and
> a lot of stuff is running it has always bailed out on me.
>
> Sascha
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
In case it helps - I think I have FastCGI working with Apache 2.0.53 on
Windows XP SP2 now, after hours of trial and error.

I am just starting with Rails, have worked through the two "Rolling with
Ruby on Rails" tutorials using WEBrick, and am moving on to the "Four
Days on Rails" article, which uses Apache/FastCGI (but doesn''t
explain
how to set it up).

The following notes distil out the successful bits of what I did.  (I
haven''t been back to square one and worked through again to check, so
it''s possible I have missed something.)

I downloaded Apache 2.0.53 and installed it using all the defaults.

Following "Four Days on Rails", I made a c:\www\webroot directory.
In there, I executed

   rails ToDo

Following the directions in "Four Days on Rails", for local use on
this
PC, I added to C:\WINDOWS\system32\drivers\etc\hosts

   127.0.0.1    todo

and added to the Apache conf\httpd.conf file

<VirtualHost *>
    ServerName todo
    DocumentRoot /www/webroot/ToDo/public
    <Directory /www/webroot/ToDo/public/ >
        Options ExecCGI FollowSymlinks
        AllowOverride all
        Allow from all
        Order allow,deny
    </Directory>
</VirtualHost>

...so when I''m ready, I should find my application at

    http://todo/

Still in httpd.conf, I uncommented the following lines:

LoadModule rewrite_module modules/mod_rewrite.so

AddHandler cgi-script .cgi

(Use the configuration checker, then restart Apache.)

I changed the shebang line in ToDo\public\dispatch.* (3 files) to

#!c:\ruby\bin\rubyw.exe

Now I can look at

    http://todo/

and see the Rails introduction.

I downloaded the One-Click Ruby for Apache Installer from

   http://rubyforge.org/projects/rubyforapache

and installed it.

Following the instructions in its README file:

Add these to httpd.conf:

LoadModule fastcgi_module modules/mod_fastcgi.so

<IfModule mod_fastcgi.c>
    AddHandler fastcgi-script .fcgi
</IfModule>

(Check the configuration, restart Apache.)

In the "default rewriting rules" section of ToDo\public\.htaccess
change
any occurrences of "dispatch.cgi" to "dispatch.fcgi"

There''s one:

RewriteRule ^(.*)$ /dispatch.fcgi?$1 [QSA,L]

Now I can still look at

    http://todo/

and see the Rails introduction.

Windows Task Manager shows three rubyw.exe processes each with about 18
MB. Restart Apache and they go away (until the next Rails request).

Viewing the Rails introduction and tapping the refresh button slowly, I
can see the CPU hit on each rubyw.exe process in turn.

So.. it looks as if FastCGI is working, and I can go on to build the
application.

regards

    Justin