FastCGI cannot start; Rails doesn't work

I have a problem deploying FastCGI for use with RoR.

OS: FreeBSD 5.4
Apache: 2.0.55
FastCGI: 2.4.2

I compiled a new mod_fastcgi.so and copied it to
/usr/lib/apache/mod_fastcgi.so

My httpd.conf looks like this:
LoadModule fastcgi_module /usr/lib/apache/mod_fastcgi.so

AddHandler fastcgi-script .fcgi

The testscript i want to execute is the following:

#!/usr/local/bin/ruby
require ‘cgi’
require ‘rubygems’
require_gem ‘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}
\n)
end
cgi.out{content}
end

#######

The errors i get in apache’s error_log are:

[Tue Jan 10 16:55:14 2006] [notice] Apache/2.0.55 (Unix)
mod_perl/1.99_17-dev Perl/v5.8.7 PHP/4.4.0 FrontPage/5.0.2.2635
mod_fastcgi/2.4.2 mod_ssl/2.0.55 OpenSSL/0.9.7e configured – resuming
normal operations
[Tue Jan 10 16:55:32 2006] [warn] FastCGI: (dynamic) server
“/home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/test.fcgi”
started (pid 18781)
FastCGI: can’t start server
“/home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/test.fcgi”
(pid 18781), execle() failed: No such file or directory
[Tue Jan 10 16:55:32 2006] [warn] FastCGI: (dynamic) server
“/home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/test.fcgi”
(pid 18781) terminated by calling exit with status ‘255’

What did i find out?
There are only a few examples on the internet with this problem. They
all say that the first line in the script ‘#!/usr/local/bin/ruby’ points
to the wrong location. My ruby is in the correct place. Does anyone have
any idea for this problem?

Thanx in advance,

Martijn

On Tue, 2006-01-10 at 17:03 +0100, Martijn van Leeuwen wrote:

cgi.env_table.each do |k,v|

“/home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/test.fcgi”
to the wrong location. My ruby is in the correct place. Does anyone have
any idea for this problem?

You can always test the script separate of the apache setup by running
the script at the command line:

cd
/home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/
./test.fcgi

Is the ruby fcgi gem installed properly?

-Matthew B.
[email protected] :: 607 227 0871
Resume and Portfolio @ http://madhatted.com

Matthew B. schreef:

FCGI.each_cgi do |cgi| end "/home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/test.fcgi" What did i find out?

cd /home/martijn/domains/martijnvanleeuwen.nl/public_html/sponsors/public/
./test.fcgi

Is the ruby fcgi gem installed properly?

I used “gem install fcgi”

And it worked like it should, so i don’t think there were any problems
there. If i try to run an empty script file like empty.fcgi i get the
same error. So i would think the problem is with fastcgi and maybe
rights. But i can’t find out where and how. I did the FreeBSD ports
version and i compilled all stuff myself. But still have problems.

I had issues on my setup due to file permissions when I received the ‘No
such file or directory’ error. I was root when I worked on one of the
files
and had to change the ownership.

Worth a shot.

~ Ben

It would be ownership of the script files. Does apache run under the
apache user? (assuming so). Check the other documents in the www
directory and see what their premission are and compare them to yours.

Its a starting point at least.
-Nick

Nick S. wrote:

It would be ownership of the script files. Does apache run under the
apache user? (assuming so). Check the other documents in the www
directory and see what their premission are and compare them to yours.

Its a starting point at least.
-Nick

Ik checked all the ownerships, they are correct. All are the local user,
none is root.

cgi works, webrick works, but fcgi doesn’t work. I checked fastcgi out
on a perl script, but i give the same error. So i would think fastcgi
doesn’t work correctly. I also installed the FreeBSD Ports fcgid module.
(alternate for fastcgi). It doesn’t work either, i get an communication
error in my error_log.

I installed the whole bunch on my Ubuntu Desktop, and it worked almost
straight away.

I surprises me that i can’t find anything on the web about this problem.

Ben R. schreef:

I had issues on my setup due to file permissions when I received the
‘No such file or directory’ error. I was root when I worked on one of
the files and had to change the ownership.

Worth a shot.

~ Ben

You mean ownership of scriptfiles or ownership of ruby? i did it as root
too. So this could be something.

Thats kinda strange that its not running on *BSD. Never used the *BSDs
but figured it would be similar enough to the *nixs that it wouldn’t
have any issues. Odd. But at least you got it working in Ubuntu, so
you know your are doing the right steps…

Sorry I can’t be of any more help =\

-Nick

Nick S. wrote:

It would be ownership of the script files. Does apache run under the
apache user? (assuming so). Check the other documents in the www
directory and see what their premission are and compare them to yours.

Its a starting point at least.
-Nick

Ik checked all the ownerships, they are correct. All are the local user,
none is root.

cgi works, webrick works, but fcgi doesn’t work. I checked fastcgi out
on a perl script, but i give the same error. So i would think fastcgi
doesn’t work correctly. I also installed the FreeBSD Ports fcgid module.
(alternate for fastcgi). It doesn’t work either, i get an communication
error in my error_log.

I surprises me that i can’t find anything on the web about this problem.

Martijn van Leeuwen wrote:

Nick S. wrote:

It would be ownership of the script files. Does apache run under the
apache user? (assuming so). Check the other documents in the www
directory and see what their premission are and compare them to yours.

Its a starting point at least.
-Nick

Ik checked all the ownerships, they are correct. All are the local user,
none is root.

cgi works, webrick works, but fcgi doesn’t work. I checked fastcgi out
on a perl script, but i give the same error. So i would think fastcgi
doesn’t work correctly. I also installed the FreeBSD Ports fcgid module.
(alternate for fastcgi). It doesn’t work either, i get an communication
error in my error_log.

I installed the whole bunch on my Ubuntu Desktop, and it worked almost
straight away.

I surprises me that i can’t find anything on the web about this problem.

I had this problem under dragonflybsd-1.4 and freebsd-4.11 for that
matter. It came down to file ownership.

If you’re running your RoR app under web root say
/usr/local/www/data/RoR_project fcgi is running as the same user as the
apache process. I had apache running as uid = www, gid = www. Once I
did a chown -R www:www on the RoR project it worked just fine.

If you are trying to run a application owned by you from your
public_html/rails_project directory you need to have apache compiled
with suexec support.

If you didn’t compile apache WITH suexec and you are trying to run a RoR
app which is owned by your uid=my_uid it won’t work. If you recompile
apache with suexec(flag in apache port), apache/fcgi will then run a
application owned by you.

Regards,

Eric