Here’s a step-by-step guide for making Rails work with \FastCGI?.
$ curl fastcgi.com/dist/fcgi-2.4.0.tar.gz | tar xfz -
$ cd fcgi-2.4.0
$ ./configure
$ make
$ sudo make install
$ sudo gem install fcgi
If the installation fails with message “checking for fcgiapp.h… no”, you probably don’t have the \FastCGI Dev Kit installed (and you skipped steps 1 and 2 :p).
Question: At this point, I get “checking for fcgiapp.h…yes”, followed by
checking for FCGX_Accept() in -lfcgi... noWhat am I missing?
LB: To the best of my knowledge, on OS X, the mkmf mechanism in extconf.rb is causing some trouble. It attempts to pass the -arch i386 flag durings its compiler tests (resulting in a successful search for the header file, but a failed link against libfcgi). I disabled those tests and just proceeded anyway. I could not find a way to force extconf.rb to use ppc.
Note: as of 3/22/05 there is a memory leak you may want to patch
$ curl andreas-s.net/download/mod_fastcgi-panther-2.4.2.tar.gz | tar xfz -
$ cd mod_fastcgi-panther-2.4.2
$ sudo cp mod_fastcgi.so /usr/libexec/httpd/
$ sudo chmod 755 /usr/libexec/httpd/mod_fastcgi.so
OR
if you’re running the Serverlogistics Complete Apache2 package, you can download the fcgi module from versiontracker as a dmg/pkg (these work in Tiger). Just skip the “AddModule mod_fastcgi.c” line below (you’ll find your conf file in /Library/Apache2/conf/httpd.conf)
httpd.conf file (/etc/httpd/httpd.conf on Panther):
LoadModule fastcgi_module libexec/httpd/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
<VirtualHost *:80>
ServerName rails
DocumentRoot /path/to/application/public/
ErrorLog /path/to/application/log/apache.log
<Directory /path/to/application/public/>
Options ExecCGI FollowSymLinks
# Change this line for the one under
# AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Edit the .htaccess file in your_rails_app/public. Change the row
\RewriteBase /dispatch.cgi
to
\RewriteBase /dispatch.fcgi
If you are running rails .10.x I believe the following should work (instead of \RewriteBase) in public/.htaccess change:
RewriteRule ^(.*)$ /dispatch.cgi?$1 [QSA,L]
to
RewriteRule ^(.*)$ /dispatch.fcgi?$1 [QSA,L]
and maybe you have to change in your public/dispatch.fcgi the line
require 'fcgi'
to
require 'rubygems'
require_gem 'fcgi'
$ sudo apachectl restart
- How do I know my application is using FCGI. is it just forced to or can I look at something and see it is loaded correcty.
A: check your server logs. or just move the dispatch.cgi to another directory to make sure the web server is reading the dispatch.fcgi
CAUTION: If you use blanks in your directory path fastCGI will not work.