Some notes about rails, apache, fastcgi and windows

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

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

On 12/28/05, Luigi R. [email protected] 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/

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


rick
http://techno-weenie.net

Did you try SCGI + apache on windows?

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

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

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? :slight_smile:

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

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

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/
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

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.

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

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

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.

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
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

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
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