PDA

View Full Version : FCGI support?


rog
06-12-2005, 02:03 AM
I've setup Ruby on Rails after following the advice in another thread:

http://www.hardhathosting.com/community/forums/showthread.php?t=170

And now I'd like to setup Fast CGI (FCGI) (http://wiki.rubyonrails.com/rails/show/Fast+CGI+and+Apache2+for+Red+Hat+Linux+9) with Apache.

Unfortunately I'm not having much luck getting the Fast CGI development kit installed. The installation appears to succeed with no errors. However, when I go to install ruby-fcgi, I get the following:


...<snip>...
ruby extconf.rb install fcgi\nchecking for fcgiapp.h... yes
checking for FCGX_Accept() in -lfcgi... no


Any ideas? Has anyone else successfully installed FCGI and its Ruby extensions?

Chris
06-12-2005, 11:23 AM
Hey rog,

I did a search on Google and found this:

http://64.233.167.104/search?q=cache:8PA5kYeK3nEJ:wiki.rubyonrails.com/rails/show/Olle%2BJonsson+checking+for+FCGX_Accept()+in+-lfcgi...+no&hl=en&client=firefox-a
http://wiki.rubyonrails.com/rails/show/Olle+Jonsson
http://www.google.com/search?q=checking+for+FCGX_Accept%28%29+in+-lfcgi...+no

Hope this helps...

rog
06-19-2005, 05:33 AM
Yeah, I have tried that same Google search. ;)

Unfortunately, at the first two links you posted, there is an overview of the problem but not an actual solution. Notice the author trails off with "OK, now I gotta go. But the instruction seems to be..." and then he gives a vague suggestion geared towards the Windows Ruby/.NET platform. It wasn't enough of a bread-trail for me, I guess.

The installation of the Ruby gem "fcgi" is failing on what looks like a check for the fcgi library ("lfcgi"), which I think is in the FCGI Development Kit. I'm thinking the installation of the FCGI Development Kit must be problematic, even though it appears to go smoothly...

Running 'make install' on the Development Kit one more time, I notice this warning:

libtool: install: warning: `../libfcgi/libfcgi.la' has not been installed in `/usr/local/lib'

Hmm...

edit: there is another warning earlier in the 'make':

/usr/bin/install -c .libs/libfcgi.so.0.0.0 /usr/local/lib/libfcgi.so.0.0.0
/usr/bin/install: cannot create regular file `/usr/local/lib/libfcgi.so.0.0.0': Permission denied


Looks like we have narrowed down the problem. It's a permissions issue. '/usr/local/lib' is owned by root.root with 555 permissions so I can't write to that directory.

Perhaps I can install the fcgi libraries from the development kit into a different directory. Two questions:

1) What is the proper directory for such libraries on this system?

2) Once installed in the alternate directory, how do I tell applications (such as the Ruby fcgi gem) where to find the library?

Thanks,
rog

Chris
06-19-2005, 09:58 AM
Rog,

Have you tried?

./configure --prefix=/usr/local/fcgi --exec-prefix=/usr/local/fcgiLet us know if that works.

rog
06-19-2005, 03:23 PM
Chris,

Using those prefixes does eliminate the warnings and errors when installing the FCGI Development Kit.

However, I still have the same problem when attempting to install the fcgi Ruby gem, as if it still cannot find the fcgi libraries. Perhaps there is a command line option to instruct gem where the libraries are?

Here's the current command and its output:

sh-2.05$ gem install fcgi -r
Attempting remote installation of 'fcgi'
Building native extensions. This could take a while...
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/local/ruby/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1 for inspection.
ruby extconf.rb install fcgi -r\nchecking for fcgiapp.h... yes
checking for FCGX_Accept() in -lfcgi... no


Results logged to /usr/local/ruby/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/ext/gem_make.out
sh-2.05$

Chris
06-19-2005, 04:26 PM
I'm at a loss in this uncharted territory...

I did find some interesting information:

http://www.infused.org/2005/03/19/ruby-on-rails-apache-fastcgi-and-ensim/
http://forum.textdrive.com/viewtopic.php?id=3362
http://www.bigbold.com/snippets/posts/show/388
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/137498

This looks like it might be the way:
gem install fcgi --with-fcgi-include=/your/path/to/include --with-fcgi-lib=/your/path/to/lib

Let us know what you figure out...

rog
06-19-2005, 05:40 PM
Chris,

Yep. Using the following command seems to have worked:

gem install fcgi -r -- --with-fcgi-lib=/usr/local/fcgi/lib --with-fcgi-include=/usr/local/fcgi/include

Note the extra "--" before the "--with-fcgi-lib" command. That is necessary for gem to parse all of the options.

I really appreciate the help! Thanks!

Chris
06-19-2005, 07:02 PM
rog,

So did you get it all working? FastCGI, Ruby, RubyonRails? If so, what's the chance you could write up a little howto for us? I would make it worth your while. Let us know.

rog
06-19-2005, 07:21 PM
rog,

So did you get it all working? FastCGI, Ruby, RubyonRails? If so, what's the chance you could write up a little howto for us? I would make it worth your while. Let us know.

I'm 95% there. Ruby on Rails is working 100% (demo with MySQL backend here) (http://xmlareas.com/rails/recipe/list), but I don't quite have FastCGI working yet. I have the fcgi Ruby gem and the FastCGI Development Kit installed now, but haven't dealt with the Apache module yet.

Tell you what, since Ruby on Rails (and Ajax on Rails) is up and running, I'll go ahead and start a howto here (http://www.hardhathosting.com/community/forums/showpost.php?p=556&postcount=1). I'll add the FastCGI stuff as I get it finished.

rog
06-19-2005, 08:23 PM
I have the majority of the howto finished:

Ruby on Rails (with Fast CGI) Howto (http://www.hardhathosting.com/community/forums/showthread.php?t=209)

So far, it will walk you through the installation of Ruby on Rails on Hard Hat -- including Ruby, RubyGems, and Rails. There's also a link to a Rails demo.

Sometime this week I'll attempt to add instructions for Ajax on Rails and FastCGI.

Chris
06-19-2005, 08:46 PM
rog,

You are the Man !! Looking forward to your complete success.

Check your account resources...I pretty much doubled everything...enjoy!

samuel
08-10-2005, 02:57 PM
Thanks for all that.

I'm so close, now... I've got fastcgi installed, the gem installed, but I'm having trouble getting mod_fastcgi.

This is where I'm stuck:

sh-2.05$ /usr/sbin/apxs -o mod_fastcgi.so -c *.c
sh: /usr/sbin/apxs: bad interpreter: No such file or directory

rog
08-10-2005, 03:06 PM
I apologize that I still haven't finished off the fastcgi section. I've been meaning to, but my company is right in the middle of a huge move.

Perhaps Chris will have some insight on this problem.

Samuel, if possible, could you list the steps you've taken so far? Particularly, after my HOWTO stops, what additional steps have you taken? It would help us understand your problem and it would also help me complete the HOWTO.

Chris
08-11-2005, 10:43 AM
This is where I'm stuck:

sh-2.05$ /usr/sbin/apxs -o mod_fastcgi.so -c *.c
sh: /usr/sbin/apxs: bad interpreter: No such file or directory

A couple of things. /usr/sbin/apxs is owned by "root", so I am not 100% sure you can do this.

Also, you might try the full path to the mod_fastcgi.so file. For example,
sh-2.05$ /usr/sbin/apxs -o /full/path/to/mod_fastcgi.so -c *.c
Let us know how it goes.

Chris
08-11-2005, 10:53 AM
Samuel,

Actually, David just pointed out that "bad interpreter: No such file or directory" means most likely that Perl is not installed. Try installing the perl ValueApp and I bet it works.

BTW, we are expecting a detailed report on how you got it working ;)

samuel
08-12-2005, 03:54 PM
Samuel,

Actually, David just pointed out that "bad interpreter: No such file or directory" means most likely that Perl is not installed. Try installing the perl ValueApp and I bet it works.

BTW, we are expecting a detailed report on how you got it working ;)

That's it! I've got fastcgi working now. Here's what worked for me (after getting Rails up and running):

fastcgi libraries:

curl http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz | tar -xz
cd fcgi-2.4.0
./configure --prefix=/usr/local/fcgi --exec-prefix=/usr/local/fcgi
make
make install


the gem:


gem install fcgi -r -- --with-fcgi-lib=/usr/local/fcgi/lib --with-fcgi-include=/usr/local/fcgi/include


mod_fastcgi:

(Make sure Perl is installed first.)


curl http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz | tar -xz
cd mod_fastcgi-2.4.2
/usr/sbin/apxs -o mod_fastcgi.so -c *.c
/usr/sbin/apxs -i -a -n fastcgi mod_fastcgi.so


Add the following to /etc/httpd/conf/httpd.conf:


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


In your_rails_app/public/.htaccess, change "dispatch.cgi" to "dispatch.fgci"

Restart Apache:


/etc/rc.d/init.d/apachectl stop
/etc/rc.d/init.d/apachectl start


And that should do it, unless I've forgotten anything.

Chris
08-12-2005, 04:01 PM
Samuel,

You are the MAN!

I will do my best to turn this all into one big tutorial in our KB.

garethr
08-29-2005, 12:19 PM
Hi Chris, Rog

Tried this out and I have Rails working under WEBrick. I tried the fcgi install commands but not sure it's working?

Visting the root of the rails app (in my case Typo) /typo-2.5.5/public/dispatch.fcgi (or just /typo-2.5.5/public/) just prints the source code. Which leads me to think apache is not handing off .fcgi requests. Visting the dispatch.cgi file returns Application Error Typo could not be reached.

Any pointers or help would be great, and thanks for the tutorial. Anything else that would make any help easier to come by let me know as well.

Full paths for perusal:

http://morethanseven.net/rails/typo-2.5.5/public/dispatch.cgi
http://morethanseven.net:3000

Chris
08-29-2005, 01:59 PM
garethr,

Take a look at your shebang line:
#!/usr/bin/env ruby

If I run that command from the shell, it gives me:
sh: /usr/bin/env: No such file or directory

I think you need to change the shebang to:
/usr/local/bin/ruby

Let us know if that is it...

rog
11-27-2005, 09:45 PM
Well, I know it's been 6 months, but I finally finished the full version of the "Ruby on Rails (with FastCGI) Howto":

http://xmlareas.com/ruby-rails-howto.html

Thanks to Chris and samuel!

Chris, I am fine with you copy-and-pasting this into a KB article if it would help your users. I only ask that you keep the URL to the article intact; in case it becomes necessary to make changes, people will have a link to the current version.

Thanks again! My site is running Rails with FastCGI now!