Can't get Ruby on Rails with Apache and FastCGI

Hi!

Environment

Solaris 10
Apache 2.2.0 with fcgid_module
Ruby 1.8.4
Rails 1.2.3

I am trying to get FastCGI working. Initially I used “dispatch.cgi”
successfully but when I switched to “dispatch.fcgi” I get

====================================================
Application error
Rails application failed to start properly

and

====================================================
[Tue May 08 16:07:10 2007] [warn] (146)Connection refused: mod_fcgid:
read data from fastcgi server error.
[Tue May 08 16:07:10 2007] [error] [client 123.123.123.123] Premature
end of script headers: dispatch.fcgi

So I tried to run the script directly:

====================================================

ruby public/dispatch.fcgi
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in load_missing_constant': uninitialized constant RailsFCGIHandler (NameError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/dependencies.rb:452:in const_missing’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:464:in `const_missing’
from public/dispatch.fcgi:24
====================================================

I have read that this means that the fcgi module is missing, so I
tried installing it:

====================================================

gem install fcgi
Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install fcgi
checking for fcgiapp.h… no
checking for fastcgi/fcgiapp.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

OK, so I am missing header (and lib) files. So I installed fcgi from
http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz and reran the module
install

(The gem tool is now building against FastCGI which is used in
mod_fastcgi for Apache. The resulting fcgi module should be compatible
with the alternative mod_fcgid that I am using.)

====================================================

gem install fcgi
Bulk updating Gem source index for: http://gems.rubyforge.org
Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install fcgi
checking for fcgiapp.h… yes
checking for FCGX_Accept() in -lfcgi… yes
creating Makefile

make
gcc -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.10 -I/
usr/local/lib/ruby/1.8/sparc-solaris2.10 -I. -DHAVE_FCGIAPP_H -c
fcgi.c
In file included from /usr/local/lib/ruby/1.8/sparc-solaris2.10/ruby.h:
24,
from fcgi.c:13:
/usr/local/lib/ruby/1.8/sparc-solaris2.10/config.h:17:1: warning:
“_FILE_OFFSET_BITS” redefined
In file included from /usr/include/iso/stdarg_c99.h:34,
from /usr/include/stdarg.h:33,
from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/
include/stdio.h:14,
from fcgi.c:7:
/usr/include/sys/feature_tests.h:188:1: warning: this is the location
of the previous definition
gcc -Wl,-G -L’/usr/local/lib’ -Wl,-R’/usr/local/lib’ -o fcgi.so
fcgi.o -lfcgi -ldl -lcrypt -lm -lc

make install
./install-sh -c -m 0755 fcgi.so /usr/local/lib/ruby/gems/1.8/gems/
fcgi-0.8.7/lib
make: ./install-sh: Command not found
make: *** [/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so]
Error 127

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/
fcgi-0.8.7 for inspection.
Results logged to /proj/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/ext/
fcgi/gem_make.out

I have this twilight zone feeling. Am I on the right track? Should it
really be this hard?

Any help appreciated,
Kevin

Posted this as a bug here along with a workaround.
http://groups.google.com/group/rubyonrails-core/browse_thread/thread/1ae275218d082958

Turns out the gem version is broken anyway and the module needs to be
installed from source

$ wget sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
$ gunzip -c ruby-fcgi-0.8.6.tar.gz | tar xf -
$ cd ruby-fcgi-0.8.6
$ ruby install.rb config
$ ruby install.rb setup
$ ruby install.rb install

Now everything is working fine.