# Some notes about rails, apache, fastcgi and windows

**URL:** <https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252>\
**Category:** Rails\
**Created:** [December 28, 2005, 7:37pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252 "2005-12-28T19:37:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 28, 2005, 7:37pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/1 "2005-12-28T19:37:36Z")

</div>

hello.

i’d like to share some feelings of mine after a couple of _weeks_  
intermittent attempts to have rails applications working on windows  
(XP) with fastcgi performances under apache (2.0).

i’d say the software stack i’m using now will be fairly common as more  
and more new rails developers will join the bandwagon.

what is stunning me is the fact that, even if i’m certainly not a  
guru, i can’t say i’m a computer illiterate, and notwithstanding this  
i’m still struggling just to have an application of mine or, for  
example typo, being deployed on the most convenient platform i’ve on  
hand (i’m not saying it is the best or the greatest, i’m just say it  
is the one i’ve on hand …) after roughly two weeks of efforts.

i checked almost all posts and wiki entries on this subject, founding  
several of them somewhat discording and, unfortunately not definitive.  
as a matter of fact even if supposedly definitive articles do exists,  
such as

> **[Apache tuning for Rails and FastCGI :: scottstuff.net](https://scottstuff.net/blog/articles/2005/07/20/apache-tuning-for-rails-and-fastcgi/index.html)**
>
> There’s a surprisingly small amount of documentation out there on tuning Apache for optimum Rails performance. Almost everyone mentions the first step (use FastCGI, not regular CGI), but that’s such a huge performance boost that it’s really...

if you browse through the end of it you’ll find other people still  
struggling with the very same issues i’m still facing, yet unresolved  
…

interestingly enough, i’m not even able to see typo (the rails-based  
blog program) running successfully under a fcgi environment (i even  
attempted to have lighttpd runs under windows in order to have typo  
running, but that is another nightmare …)–btw, it works ok under  
webrick.

a final consideration: rails is great and fun to program, until you  
are going to deploy it … this segment of the stack really badly  
needs to be documented, explained in details (“why is something  
happening on this stack and not on this other one …”), and  
_effectively_ covered for the vast majority of deployment cases,  
otherwise rails will be, for the foreseeable future, just a promise in  
half.

–luigi

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 28, 2005, 7:43pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/2 "2005-12-28T19:43:39Z")

</div>

On 12/28/05, Luigi R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> guru, i can’t say i’m a computer illiterate, and notwithstanding this  
> struggling with the very same issues i’m still facing, yet unresolved  
> needs to be documented, explained in details (“why is something  
> happening on this stack and not on this other one …”), and  
> _effectively_ covered for the vast majority of deployment cases,  
> otherwise rails will be, for the foreseeable future, just a promise in  
> half.

Did you try SCGI + apache on windows?

[http://www.zedshaw.com/projects/scgi\_rails/](http://www.zedshaw.com/projects/scgi_rails/)

I believe InstantRails (the simple rails environment on windows) uses  
that method by default.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 28, 2005, 8:28pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/3 "2005-12-28T20:28:53Z")

</div>

> Did you try SCGI + apache on windows?
> 
> [http://www.zedshaw.com/projects/scgi\_rails/](http://www.zedshaw.com/projects/scgi_rails/)
> 
> I believe InstantRails (the simple rails environment on windows) uses  
> that method by default.

While SCGI is what FastCGI should strive to be in simplicity, it’s  
simply not ready for production.

Example, right now, I’m trying to reach an SCGI deployed application.  
Apache gives me a 500 internal server error, and this in the error log:

[Wed Dec 28 20:13:20 2005] [error] [client 83.91.147.101] (500)Unknown  
error 500: scgi: Unknown error 500: error reading response headers

There’s nothing in scgi.log or production.log. For this reason only, I  
don’t see SCGI a viable alternative to FastCGI.

Br,

Morten

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 28, 2005, 8:50pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/4 "2005-12-28T20:50:01Z")

</div>

I don’t know, getting rails up and running with Apache and windows  
wasn’t all the terrible for me (defiantly not as bad as hacking around  
with IIS). But, here were my steps as well as I can remember. (this  
was running on a 2003 box, but I’ll go through it on my XP box at home  
to make sure)

Install Ruby 1.82 through the window binary available.  
add c:\ruby\bin to the path env  
`gem install rails` from the command line  
get the mod\_fastcgi.dll and add it to the apache modules directory  
add the following in the httpd.conf

LoadModule fastcgi\_module modules/mod\_fastcgi.dll

 FastCgiServer "/public/dispatch.fcgi" \ -initial-env RAILS\_ENV=production \ -processes 4 -idle-timeout 60

#i have it setup as a virtual server, the following directory entry is  
for that  
\<Directory “/public”\>  
Options ExecCGI FollowSymLinks  
AllowOverride all  
Allow from all  
Order allow,deny  
AddHandler cgi-script .cgi  
AddHandler fastcgi-script .fcgi

Install ruby for apache v 1.3.1  
Get a copy of my app  
MAKE SURE THAT THE PATH FOR THE RUBY EXE IS RIGHT AT THE TOP OF THE  
DISPATCH.FCGI file! (very important and easy to miss)  
Mine looks like #!C:/ruby/bin/rubyw

and I think thats it. No registry hacking or the like was invloved. I  
was also able to upgrade rails from the 0.14.x versions to 1.0 with  
out any issues (besides one bug that cropped up).

Like I said, this was on 2003, but can’t imagine XP would be really  
any different when trying to run apache, but I’ll give it a go once I  
get home.

-Nick

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 28, 2005, 10:11pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/5 "2005-12-28T22:11:38Z")

</div>

I’ll agree that the steps needed to get Rails up and running on ANY  
stack is lack luster at best. Just look at how many e-mails on this  
list alone are about just getting stuff running!

With that being said, Rails is a new technology (they just hit 1.0)  
and I personally don’t expect it to be a walk in the park just yet  
when it comes to doing certain things. I do expect it to run though,  
with effort from my end, and so far its done that on anything I’ve  
tried it on. (I’ve gotten it running on apache(linux/windows/OS X) and  
under IIS)

Rails right now is still very narrow minded when it comes to what  
platforms it runs on (and with what amount of effort each platform  
needs). This is a reflection of how/why it was developed in the first  
case, and will only change in time.

All in all, I haven’t found Rails to be much more difficult then any  
other web based framework of similar age. (never used it, but what was  
PHP 1.0 like to setup?) And has anyone ever tried to get a J2EE stack  
going? 🙂

Well thats my rant on the subject anyways. Like I said, I’ll try to  
get my home box up and running as soon as I can and will report on how  
that goes, with the steps I took.

-Nick

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 28, 2005, 9:38pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/6 "2005-12-28T21:38:19Z")

</div>

Hello Nick, thanks for sharing your configuration.

I may possibly have forgot some steps, or not correctly executed some  
instructions found in some posts or resources on the web. In a few  
days I may give it another try.

My point though is that, based on the various resources I found  
available on the web (wikis, web sites, emails), and based on repeated  
issues raised about fcgi (like the infamous: “FastCGI: incomplete  
headers (35 bytes) received from server”) there doesn’t seem (yet) to  
be a clear definitive solution, working in _all_ (most) circumstances,  
or at least a clearly precise and detailed explanation of the  
interactions between the required software components on the windows  
platform for the rails+apache+fcgi stack, so to take the corrective  
actions and solve the problem, rather than a brutal trial and error  
approach.

–L

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 29, 2005, 2:52am UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/7 "2005-12-29T02:52:51Z")

</div>

Ok, so I went through the setup on my XP SP 2 machine here at home.

For the most part I followed  
[http://wiki.rubyonrails.com/rails/pages/HowToInstall+Fast+CGI+and+Apache2+for+Windows+XP/](http://wiki.rubyonrails.com/rails/pages/HowToInstall+Fast+CGI+and+Apache2+for+Windows+XP/)  
to the letter, as I did with 2003 box. Once I type in the right  
path(!) everything was up and running in about 20mins. I didn’t have  
ruby installed at all here, so it was all from the beginning.

I used:  
Ruby 1.8.2 Windows Installer  
`gem install rails --include dependencies`  
RubyForApache 1.3.1 (I forgot this at first, and it wasn’t working so  
well)  
mod\_fastcgi-2.4.2.dll  
`rails test` to generate a silly little app.

One those are installed I made the changes to the httpd.conf as noted  
on the wiki page. The one extra bit I added was the FastCGIServer part  
I noted in my previous e-mail.

That was it. Granted my little test app doesn’t connect to a database  
or anything, but it should work for real apps too, and has for me.

Hope this helps somehow.  
-Nick

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 29, 2005, 3:29am UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/8 "2005-12-29T03:29:00Z")

</div>

I really liked SCGI and would have switched to using it over FCGI but  
we’re  
running Apache 2 on Linux and there is no good way to have Apache  
connect to  
the different instances of an SCGI cluster (I guess it works with  
lighttpd)  
so you are limited to one connection which killed our performance and  
scalability.

Until Apache’s mod\_scgi knows how to connect to multiple SCGI listeners  
and  
dispatch requests properly, no go for us.

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 29, 2005, 4:47am UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/9 "2005-12-29T04:47:13Z")

</div>

Morten,

Considering other people have this configuration running do you think  
you just might have your configuration wrong? Why don’t you send me  
your apache config and I’ll see if I can debug it.

BTW, I’d say SCGI is fairly ready for production if you use lighttpd.  
If you need to use Apache then please place the blame properly on the  
apache configuration and mod\_scgi. I’ve run several fairly high volume  
sites using lighttpd and scgi with no problems.

Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

On Wed, 28 Dec 2005 20:26:16 +0100

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 29, 2005, 6:35am UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/10 "2005-12-29T06:35:45Z")

</div>

Zed,

Do you know if mod\_scgi is being maintained?

I wonder what it would take to get it in shape for Apache?

I’d love to move over to SCGI.

Cheers.

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 29, 2005, 10:04am UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/11 "2005-12-29T10:04:26Z")

</div>

Hi Zed,

> Considering other people have this configuration running do you think  
> you just might have your configuration wrong? Why don’t you send me  
> your apache config and I’ll see if I can debug it.

It’s quite likely my installation, but with SCGI being so simple, I  
don’t see how I can get it wrong. Also, this works for the first period  
of time after which it breaks:

\<VirtualHost 213.150.40.246\>  
ServerName [weblog.tagticks.com](http://weblog.tagticks.com)  
DocumentRoot /home/tagticks/sites/weblog/typo-2.6.0/public/

SCGIMount / 127.0.0.1:10001

\<LocationMatch “/(stylesheets|images|javascripts|favicon|robots).\*$”\>  
SCGIHandler Off

> BTW, I’d say SCGI is fairly ready for production if you use lighttpd.  
> If you need to use Apache then please place the blame properly on the  
> apache configuration and mod\_scgi. I’ve run several fairly high volume  
> sites using lighttpd and scgi with no problems.

That’s good to head. I really appreciate the way you’ve done SCGI. I  
really appreciate Apache2. I think the issue is somewhere in between, a  
theory of mine is that it’s a hanging MySQL connection that’s the root  
cause. This is a vanilla Typo 2.6.0 installation that has been doing  
nothing over night.

If lighty is the way to go, so be it. I just use Apache2 extensively for  
other sites on that machine and would prefer to keep doing that.

Br,

Morten

---

<div class="post-metadata">

**Author:** ![luigi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/73ab20/32.png) [@luigi](https://www.ruby-forum.com/u/luigi)\
**Post date:** [December 29, 2005, 3:18pm UTC](https://www.ruby-forum.com/t/some-notes-about-rails-apache-fastcgi-and-windows/51252/12 "2005-12-29T15:18:11Z")

</div>

Hi Zed,

> Considering other people have this configuration running do you think  
> you just might have your configuration wrong? Why don’t you send me  
> your apache config and I’ll see if I can debug it.

It’s quite likely my installation, but with SCGI being so simple, I  
don’t see how I can get it wrong. Also, this works for the first period  
of time after which it breaks:

\<VirtualHost 213.150.40.246\>  
ServerName [weblog.tagticks.com](http://weblog.tagticks.com)  
DocumentRoot /home/tagticks/sites/weblog/typo-2.6.0/public/

SCGIMount / 127.0.0.1:10001

\<LocationMatch “/(stylesheets|images|javascripts|favicon|robots).\*$”\>  
SCGIHandler Off

> BTW, I’d say SCGI is fairly ready for production if you use lighttpd.  
> If you need to use Apache then please place the blame properly on the  
> apache configuration and mod\_scgi. I’ve run several fairly high  
> volume  
> sites using lighttpd and scgi with no problems.

That’s good to hear. I really appreciate the way you’ve done SCGI. I  
really appreciate Apache2. I think the issue is somewhere in between, a  
theory of mine is that it’s a hanging MySQL connection that’s the root  
cause. This is a vanilla Typo 2.6.0 installation that has been doing  
nothing over night.

If lighty is the way to go, so be it. I just use Apache2 extensively for  
other sites on that machine and would prefer to keep doing that.

Br,

Morten
