Forum: Ruby on Rails FastCGI cannot start; Rails doesn't work

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C6ca569623cbe34b08595aca0d363696?d=identicon&s=25 Martijn van Leeuwen (Guest)
on 2006-01-10 17:05
(Received via mailing list)
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

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

######

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}<br>\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
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2006-01-10 17:23
(Received via mailing list)
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 Beale
mixonic@synitech.com :: 607 227 0871
Resume and Portfolio @ http://madhatted.com
234baba7870c09d73a2805438a75d36d?d=identicon&s=25 Martijn van Leeuwen (Guest)
on 2006-01-10 18:45
(Received via mailing list)
Matthew Beale schreef:

>>
>></IfModule>
>> 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.
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstien (Guest)
on 2006-01-10 19:27
(Received via mailing list)
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
234baba7870c09d73a2805438a75d36d?d=identicon&s=25 Martijn van Leeuwen (Guest)
on 2006-01-10 19:33
(Received via mailing list)
Ben Reubenstien 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.
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-01-10 20:03
(Received via mailing list)
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
234baba7870c09d73a2805438a75d36d?d=identicon&s=25 Martijn van Leeuwen (Guest)
on 2006-01-11 14:18
Nick Stuart 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.
234baba7870c09d73a2805438a75d36d?d=identicon&s=25 Martijn van Leeuwen (Guest)
on 2006-01-11 14:52
(Received via mailing list)
Nick Stuart 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.
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-01-11 15:54
(Received via mailing list)
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
7691b32e919d8579914810669bd5570e?d=identicon&s=25 Eric Chet (Guest)
on 2006-01-11 18:14
Martijn van Leeuwen wrote:
> Nick Stuart 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
This topic is locked and can not be replied to.