Apache2, FastCGI and Rails on Windows

W

Williams, Chris

------_=_NextPart_001_01C4E208.F2C1C7C1
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I've been running around in circles trying to enable FastCGI on my rails
install.

I've modified my http.conf to load the fastcgi module and add it as the
handler for .fcgi
I've modified my .htaccess to redirect to dispatch.fcgi, and that is
working.=20

What happens is that Rails throws back the 500 page with an error, and
Apache's error log show's the following:

[Tue Dec 14 12:56:09 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" started (pid 1636)
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] (OS 109)The pipe
has been ended. : FastCGI: comm with server
"C:/epc/blog/public/dispatch.fcgi" aborted: GetOverlappedResult() failed
[Tue Dec 14 12:56:11 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 1636) terminated with exit with
status '1'
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] FastCGI:
incomplete headers (0 bytes) received from server
"C:/epc/blog/public/dispatch.fcgi"
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] File does not
exist: C:/Program Files/Apache Group/Apache2/htdocs/favicon.ico
[Tue Dec 14 12:56:14 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 2472)
[Tue Dec 14 12:56:16 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 2472) terminated with exit with
status '1'
[Tue Dec 14 12:56:19 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 3652)
[Tue Dec 14 12:56:20 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 3652) terminated with exit with
status '1'
[Tue Dec 14 12:56:24 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 2120)
[Tue Dec 14 12:56:26 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 2120) terminated with exit with
status '1'
[Tue Dec 14 12:56:26 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" has failed to remain running for 30
seconds given 3 attempts, its restart interval has been backed off to
600 seconds

It seems to be unable to communicate over the default pipe. Has anyone
managed to get this working? What am I doing wrong?

Thanks,
Chris

------_=_NextPart_001_01C4E208.F2C1C7C1--
 
S

Sarah Tanembaum

I've been running around in circles trying to enable FastCGI on my rails
install.

I've modified my http.conf to load the fastcgi module and add it as the
handler for .fcgi
I've modified my .htaccess to redirect to dispatch.fcgi, and that is
working.

What happens is that Rails throws back the 500 page with an error, and
Apache's error log show's the following:

[Tue Dec 14 12:56:09 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" started (pid 1636)
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] (OS 109)The pipe
has been ended. : FastCGI: comm with server
"C:/epc/blog/public/dispatch.fcgi" aborted: GetOverlappedResult() failed
[Tue Dec 14 12:56:11 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 1636) terminated with exit with
status '1'
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] FastCGI:
incomplete headers (0 bytes) received from server
"C:/epc/blog/public/dispatch.fcgi"
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] File does not
exist: C:/Program Files/Apache Group/Apache2/htdocs/favicon.ico
[Tue Dec 14 12:56:14 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 2472)
[Tue Dec 14 12:56:16 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 2472) terminated with exit with
status '1'
[Tue Dec 14 12:56:19 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 3652)
[Tue Dec 14 12:56:20 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 3652) terminated with exit with
status '1'
[Tue Dec 14 12:56:24 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 2120)
[Tue Dec 14 12:56:26 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 2120) terminated with exit with
status '1'
[Tue Dec 14 12:56:26 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" has failed to remain running for 30
seconds given 3 attempts, its restart interval has been backed off to
600 seconds

It seems to be unable to communicate over the default pipe. Has anyone
managed to get this working? What am I doing wrong?

Thanks,
Chris
I went thru all with no luck. I don't think Windows implementation other
than the Ruby core(thanks Matz) is any good, at best it will get you
frustrated. Prior to that I've tried to get Apache2, mod_ruby/eruby to
work, but no luck.

I don't think that they care so much for Windows users. Perhaps anyone
can prove me wrong.
 
K

Kent Sibilev

I'm running my rails application on the same environment and it works
fine. Make sure your application doesn't raise any exceptions and dies
killing the communication pipe.

Cheers,
Kent.
 
K

Kent Sibilev

I agree that it doesn't make too much sense to use Apache2 + mod_ruby
on Windows, simply because Ruby doesn't support native threads. You
still can configure it, but all your requests will be queued to the
single Ruby interpreter. But you can configure Apache2 + mod_fastcgi on
Windows and run as many ruby processes as you want.

Check out http://rubyforge.org/projects/rubyforapache

Cheers,
Kent.
 
S

Sarah Tanembaum

Kent said:
I'm running my rails application on the same environment and it works
fine. Make sure your application doesn't raise any exceptions and dies
killing the communication pipe.

Cheers,
Kent.
I've been running around in circles trying to enable FastCGI on my rails
install.

I've modified my http.conf to load the fastcgi module and add it as the
handler for .fcgi
I've modified my .htaccess to redirect to dispatch.fcgi, and that is
working.

What happens is that Rails throws back the 500 page with an error, and
Apache's error log show's the following:

[Tue Dec 14 12:56:09 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" started (pid 1636)
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] (OS 109)The pipe
has been ended. : FastCGI: comm with server
"C:/epc/blog/public/dispatch.fcgi" aborted: GetOverlappedResult() failed
[Tue Dec 14 12:56:11 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 1636) terminated with exit with
status '1'
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] FastCGI:
incomplete headers (0 bytes) received from server
"C:/epc/blog/public/dispatch.fcgi"
[Tue Dec 14 12:56:11 2004] [error] [client 127.0.0.1] File does not
exist: C:/Program Files/Apache Group/Apache2/htdocs/favicon.ico
[Tue Dec 14 12:56:14 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 2472)
[Tue Dec 14 12:56:16 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 2472) terminated with exit with
status '1'
[Tue Dec 14 12:56:19 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 3652)
[Tue Dec 14 12:56:20 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 3652) terminated with exit with
status '1'
[Tue Dec 14 12:56:24 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" restarted (pid 2120)
[Tue Dec 14 12:56:26 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" (pid 2120) terminated with exit with
status '1'
[Tue Dec 14 12:56:26 2004] [warn] FastCGI: (dynamic) server
"C:/epc/blog/public/dispatch.fcgi" has failed to remain running for 30
seconds given 3 attempts, its restart interval has been backed off to
600 seconds

It seems to be unable to communicate over the default pipe. Has anyone
managed to get this working? What am I doing wrong?

Thanks,
Chris
How do you test if fastcgi is working? I know that the apache loaded the
fastcgi modules correctly. Now, how do you configure fastcgi in
Apache2 so it will work with ruby. Using just standard cgi, I can run
ruby.cgi with no probs, except the startup time a bit longer than usual.

Thanks.
 
K

Kent Sibilev

Oh, This is quite easy. I assume you have Ruby and RubyForApache
installed.

1. Edit Apache's httpd.conf file by adding the following:

LoadModule fastcgi_module modules/mod_fastcgi.so

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

2. Create test.fcgi file in (for example) c:\Program Files\Apache
Group\Apache2\cgi-bin directory with this content:

#!c:\ruby\bin\rubyw.exe
require 'fcgi'
counter = 0
FCGI.each_cgi('html3') do |cgi|
counter += 1
cgi.out {
cgi.html {
cgi.body {
cgi.h1 { "Hello World!" } +
cgi.p { "Counter: #{counter}" }
}
}
}
end

3. Hit http://localhost/cgi-bin/test.fcgi

Cheers,
Kent.
 
J

Joao Pedrosa

Hi,

Kent, you have been very helpful for us Windows users by putting
together mod_ruby and fastcgi in an easy to install package. Thank you
very much for that. It's like a dream coming true (ok Ruby web support
on Windows.)

Thank you. I hope you can keep it going until the community pick it up. :)

Cheers,
Joao
 
G

gabriele renzi

Joao Pedrosa ha scritto:
Hi,

Kent, you have been very helpful for us Windows users by putting
together mod_ruby and fastcgi in an easy to install package. Thank you
very much for that. It's like a dream coming true (ok Ruby web support
on Windows.)

Thank you. I hope you can keep it going until the community pick it up. :)

Cheers,
Joao

+1, and I actually got it even before you announced it :)
btw, I wonder if you could provide some bigger installer with lots of
ggodies (i.e. sqlite, apache itself..)
But maybe that would be a band hog for rubyforge :/
 
C

Curt Hibbs

gabriele said:
Joao Pedrosa ha scritto:

+1, and I actually got it even before you announced it :)
btw, I wonder if you could provide some bigger installer with lots of
ggodies (i.e. sqlite, apache itself..)
But maybe that would be a band hog for rubyforge :/

Darn it, I wanted to keep this quiet for a while, but this is forcing my
hand... :-(

I've been planning a One-Click Ruby Server as a server-side complement to
the One-Click Ruby Installer, that would be precisely what you are asking
for. I've privately asked Kent to join forces on this (although, that was so
recent that he could see this posting first). Don't know if he's interested,
but we'll see.

In the meantime, if anyone wants to send me suggestions on what they would
like to see included, please send me a private email with "One-Click Ruby
Server" in the subject (to avoid my spam filters -- send to curt at hibbs
dot com.

Thanks,
Curt
 
G

gabriele renzi

Curt Hibbs ha scritto:
Darn it, I wanted to keep this quiet for a while, but this is forcing my
hand... :-(

sorry for spoiling :/
I've been planning a One-Click Ruby Server as a server-side complement to
the One-Click Ruby Installer, that would be precisely what you are asking
for. I've privately asked Kent to join forces on this (although, that was so
recent that he could see this posting first). Don't know if he's interested,
but we'll see.

In the meantime, if anyone wants to send me suggestions on what they would
like to see included, please send me a private email with "One-Click Ruby
Server" in the subject (to avoid my spam filters -- send to curt at hibbs
dot com.

I'm starting to feel guilty looking at you handling so many projects,
time to say thanks for everything :)
 
K

Kent Sibilev

I'm really sorry about that. I didn't know about your plans. The main
reason I started this project was that my two colleges are 'hopeless'
Windows users and they always complained about their inability to run
our applications on their laptops. But I agree this kind of project
needs some further development and I would gladly join the forces.

Cheers,
Kent.
 
C

Curt Hibbs

Kent Sibilev tp:
I'm really sorry about that. I didn't know about your plans. The main
reason I started this project was that my two colleges are 'hopeless'
Windows users and they always complained about their inability to run
our applications on their laptops. But I agree this kind of project
needs some further development and I would gladly join the forces.

Excellent! We can discuss how to get this rolling off-list.

Curt
 
C

Curt Hibbs

gabriele said:
Curt Hibbs ha scritto:


sorry for spoiling :/


I'm starting to feel guilty looking at you handling so many projects,
time to say thanks for everything :)

Your welcome... and thanks for the vote of confidence!

Curt

PS
Please *do* let me know what you think should be included in a one-click
ruby server.
 
G

Gavin Sinclair

Please *do* let me know what you think should be included in a one-click
ruby server.

All the software you need and dead-simple instructions for getting it
working :) Plus a bunch of links telling me why I should _care_ about
Apache2, etc. (I already know about FastCGI and Rails, but I guess
they should get the same treatment.)

Gavin
 
S

Sarah Tanembaum

Kent said:
Oh, This is quite easy. I assume you have Ruby and RubyForApache installed.

1. Edit Apache's httpd.conf file by adding the following:

LoadModule fastcgi_module modules/mod_fastcgi.so

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

2. Create test.fcgi file in (for example) c:\Program Files\Apache
Group\Apache2\cgi-bin directory with this content:

#!c:\ruby\bin\rubyw.exe
require 'fcgi'
counter = 0
FCGI.each_cgi('html3') do |cgi|
counter += 1
cgi.out {
cgi.html {
cgi.body {
cgi.h1 { "Hello World!" } +
cgi.p { "Counter: #{counter}" }
}
}
}
end

3. Hit http://localhost/cgi-bin/test.fcgi

Cheers,
Kent.
May be I did something wrong. I have not been able to run fcgi, and yes,
I did try your sample script. So, I test using 'irb' if there are error ...

% irb
LoadError: No such file to load -- fcgi
from
c:/apps/ruby/ruby-1.8/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in
`require__'
from
c:/apps/ruby/ruby-1.8/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in
`require' from (irb):1
irb(main):002:0>

Any idea?

Sarah
 
J

Joao Pedrosa

Hi,

May be I did something wrong. I have not been able to run fcgi, and yes,
I did try your sample script. So, I test using 'irb' if there are error ...

% irb
LoadError: No such file to load -- fcgi
from
c:/apps/ruby/ruby-1.8/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in
`require__'
from
c:/apps/ruby/ruby-1.8/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in
`require' from (irb):1
irb(main):002:0>

Any idea?

Sarah

Please confirm that the files are where they are supposed to be. For
comparision, I'm providing the locations of the files on my system:
C:\desenvolvimento\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\fcgi.so
C:\Arquivos de programas\Apache Group\Apache2\modules\mod_fastcgi.so

My httpd.conf has this:

LoadModule fastcgi_module modules/mod_fastcgi.so

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

LoadModule ruby_module modules/mod_ruby.so

<IfModule mod_ruby.c>
# for Apache::RubyRun
RubyRequire apache/ruby-run

# exec files under /ruby as ruby scripts.
<Location /ruby>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
Options +ExecCGI
</Location>

# exec *.rbx as ruby scripts.
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
</IfModule>

And finally, my sample scripts:
C:\Arquivos de programas\Apache Group\Apache2\cgi-bin\hm.fcgi

#!C:/desenvolvimento/ruby/bin/ruby.exe
require 'fcgi'
counter = 0
FCGI.each_cgi('html3') do |cgi|
counter += 1
cgi.out {
cgi.html {
cgi.body {
cgi.h1 { "Hello World!" } +
cgi.p { "Counter: #{counter}" }
}
}
}
end


And:
C:\Arquivos de programas\Apache Group\Apache2\htdocs\ruby\hw.rbx
require "cgi"

cgi = CGI.new
print cgi.header("type"=>"text/plain")
print "hello world"


I have been able to setup rails using fastcgi on Windows, thanks to Kent. :)

Cheers,
Joao
 
S

Sarah Tanembaum

Joao said:
Hi,




Please confirm that the files are where they are supposed to be. For
comparision, I'm providing the locations of the files on my system:
C:\desenvolvimento\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\fcgi.so
C:\Arquivos de programas\Apache Group\Apache2\modules\mod_fastcgi.so

My httpd.conf has this:

LoadModule fastcgi_module modules/mod_fastcgi.so

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

LoadModule ruby_module modules/mod_ruby.so

<IfModule mod_ruby.c>
# for Apache::RubyRun
RubyRequire apache/ruby-run

# exec files under /ruby as ruby scripts.
<Location /ruby>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
Options +ExecCGI
</Location>

# exec *.rbx as ruby scripts.
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
</IfModule>

And finally, my sample scripts:
C:\Arquivos de programas\Apache Group\Apache2\cgi-bin\hm.fcgi

#!C:/desenvolvimento/ruby/bin/ruby.exe
require 'fcgi'
counter = 0
FCGI.each_cgi('html3') do |cgi|
counter += 1
cgi.out {
cgi.html {
cgi.body {
cgi.h1 { "Hello World!" } +
cgi.p { "Counter: #{counter}" }
}
}
}
end


And:
C:\Arquivos de programas\Apache Group\Apache2\htdocs\ruby\hw.rbx
require "cgi"

cgi = CGI.new
print cgi.header("type"=>"text/plain")
print "hello world"


I have been able to setup rails using fastcgi on Windows, thanks to Kent. :)

Cheers,
Joao
Hi Joao, thanks for walking me thru. You are right, I have no fcgi.o in
the path you specified. Where can I download fcgi.o for mswin32?

Thanks a bunch

Sarah
 
J

Joao Pedrosa

Hi,
Hi Joao, thanks for walking me thru. You are right, I have no fcgi.o in
the path you specified. Where can I download fcgi.o for mswin32?

Thanks a bunch

Sarah

You can download the package by Kent at:
http://rubyforge.org/frs/download.php/2183/RubyForApache-beta1.exe

It will install the files for you, as long as you provide the
installer with the correct paths. At least for me, the installer
sometimes added an extra /RubyForApache at the wrong time, so if I
just clicked to install the files there they would get installed in
the wrong directory. So you have to be careful to correct the
installer when needed.

You will need to provide 3 paths for it. One will be the apache
directory, another will be the Ruby directory, and the last will be a
RubyForApache directory. I'm not sure about the order in which they
will be asked, just make sure they are correct. So in my system they
would be:

1) C:\Arquivos de programas\Apache Group\Apache2

2) C:\desenvolvimento\ruby

3) C:\desenvolvimento\ruby\RubyForApache

Make the necessary adjustments for you system and you should get it
installed correctly. :)

Cheers,
Joao
 
S

Sarah Tanembaum

Joao said:
Hi,




You can download the package by Kent at:
http://rubyforge.org/frs/download.php/2183/RubyForApache-beta1.exe

It will install the files for you, as long as you provide the
installer with the correct paths. At least for me, the installer
sometimes added an extra /RubyForApache at the wrong time, so if I
just clicked to install the files there they would get installed in
the wrong directory. So you have to be careful to correct the
installer when needed.

You will need to provide 3 paths for it. One will be the apache
directory, another will be the Ruby directory, and the last will be a
RubyForApache directory. I'm not sure about the order in which they
will be asked, just make sure they are correct. So in my system they
would be:

1) C:\Arquivos de programas\Apache Group\Apache2

2) C:\desenvolvimento\ruby

3) C:\desenvolvimento\ruby\RubyForApache

Make the necessary adjustments for you system and you should get it
installed correctly. :)

Cheers,
Joao
Thanks for sharing your experience with me, now I can run Ruby
fcgi/fastcgi and mod_ruby on Windows for the first time. Thanks.
 
S

Sarah Tanembaum

Kent said:
I agree that it doesn't make too much sense to use Apache2 + mod_ruby on
Windows, simply because Ruby doesn't support native threads. You still
can configure it, but all your requests will be queued to the single
Ruby interpreter. But you can configure Apache2 + mod_fastcgi on Windows
and run as many ruby processes as you want.

Check out http://rubyforge.org/projects/rubyforapache

Cheers,
Kent.
Kent, you are an angel and thanks for your fine contribution.
I've search and tried many different method to get mod_ruby and fcgi to
work for quite a while, and for the first time, I can get it to work
with many of fcgi sample scripts(that was never work before, but now
they do) including yours as well.

Thanks again and now I can actually start learning Programing Ruby for
the Web.

Sarah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top