On Tue, 30 Sep 2003, Carl Youngblood wrote:

> Hello,  I'm trying to set up ruby-fastcgi on redhat 9.  Everything seems to
> be set up right, but I get an error in my apache logs when I try to access a
> simple fcgi ruby script:
>
> [Tue Sep 30 01:15:54 2003] [alert] [client 127.0.0.1] (13)Permission denied:
> FastCGI: failed to connect to (dynamic) server "/var/www/cgi-bin/test.fcgi":
> something is seriously wrong, any chance the socket/named_pipe directory was
> removed?, see the FastCgiIpcDir directive

this means that either

  a) the program did not run at all
  b) the program ran, but spat out bad things

your program is a valid fcgi program - it runs on my host - so it's not b.

so, you obviously have apache set up, and configured for, mod_fastcgi since
the error logs have those messages.

a few easy things to consider:

first, what is the output of

  ~ > which -a ruby
  ~ > sudo su nobody -c './test.fcgi < /dev/null'

  eg - can you run your program as user nobody (or whatever the web server
  runs as) from the command line?  of course you could eliminate this
  possibility by simply

  ~ > chmod 755 ./test.fcgi
  ~ > ./test.fcgi < /dev/null

if not

    do you have multiple installations of ruby? (1.6.8 and 1.8.0)
      if so, do you have ruby-fcgi installed for each site_ruby dir?

i guess all that stuff may seem obvious - but i had to throw it out there...

about the only thing i have run across with ruby cgi programs that use modules
crashing is that, when you compile a module, say ruby-fcgi, it may depend on
other libraries:

  ruby-fcgi -> libfastcgi.so

you can see this by, for example:

~ > ldd /usr/local/ruby-1.8.0/lib/ruby/site_ruby/1.8/i686-linux/fcgi.so
        libfcgi.so.0 => /usr/local/lib/libfcgi.so.0 (0x40012000)
        libc.so.6 => /lib/libc.so.6 (0x4001c000)
        libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x40152000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x4015a000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2aaaa000)

so, when any program runs that requires 'fcgi.so', it, in turn, will cause the
linker to look for all the other libs it needs.  sometimes the paths will be
incomplete and the linker will need to look for the others in LD_LIBRARY_PATH
or /etc/ld.so.conf.  it can happen (it has to me)  that a module _you_ require
works completely find because the directory of the libs _it_ depends on are in
your LD_LIBRARY_PATH and ld.so can find them.  however, when you are running a
cgi it is user nobody that is running the script and his LD_LIBRARY_PATH may
not have a path where the depending lib can be found.  i think i saw this with
the postgres module before... any how, you can fix it by configuring ld.so
(/etc/ld.so.conf) _or_ by compiling with LD_RUN_PATH set, which hard codes the
paths into the shared module.  or by setting the global LD_LIBRARY_PATH but i
forget how to do that.

the only reason i point that out is that redhat routinely does NOT have
/usr/local/lib configured as a place for ld.so to look and many packages will
install their libs exactly there.

-a

> A while back I was able to set up ruby-fcgi on a gentoo installation of
> linux without ever running into this problem.  Does anybody have any ideas
> about what might be wrong?
>
> Thanks,
> Carl Youngblood
>
> P.S.  In case it's helpful, here is the sample script I'm trying to run:
>
> #!/usr/local/bin/ruby
> require 'cgi'
> require 'fcgi'
>
> FCGI.each_cgi do |cgi|
>    content = ''
>    env = []
>    cgi.env_table.each do |k,v|
>      env << [k,v]
>    end
>    env.sort!
>    env.each do |k,v|
>      content << %Q(#{k} => #{v}<br>\n)
>    end
>    cgi.out{content}
> end
>
>

  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328
  | Email: ara.t.howard / noaa.gov
  | Phone:  303-497-7238
  | Fax:    303-497-7259
  | The difference between art and science is that science is what we understand
  | well enough to explain to a computer.  Art is everything else.
  |   -- Donald Knuth, "Discover"
  | ~ > /bin/sh -c 'for lang in ruby perl; do $lang -e "print \"\x3a\x2d\x29\x0a\""; done'
  ====================================