More fcgi problems


#1

Finally got fcgi installed with apache. Now whe I click on “About your
application’s environment” on the Rails Welcome page, it simply prints
out the dispatch.fcgi script as shown below. I would appreciate any help
I can get on this. I can provide other infomation if necessary.

#!/usr/local/bin/ruby

You may specify the path to the FastCGI crash log (a log of unhandled

exceptions which forced the FastCGI instance to exit, great for

debugging)

and the number of requests to process before running garbage

collection.

By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log

and the GC period is nil (turned off). A reasonable number of

requests

could range from 10-100 depending on the memory footprint of your app.

Example:

# Default log path, normal GC behavior.

RailsFCGIHandler.process!

# Default log path, 50 requests between GC.

RailsFCGIHandler.process! nil, 50

# Custom log path, normal GC behavior.

RailsFCGIHandler.process! ‘/var/log/myapp_fcgi_crash.log’

require File.dirname(FILE) + “/…/config/environment”
require ‘fcgi_handler’

RailsFCGIHandler.process!


#2
  1. Ensure FastCGIServer is set up in your httpd.conf file to point to
    your dispatch.fcgi file
  2. Ensure that FastCGI module is loaded
  3. Ensure that dispatch.fcgi has execuite privileges enabled for your
    web user
  4. Ensure that your .htaccess file is directing requests to
    dispatch.fcgi

#3

Does you see anything wrong with any of this?

FastCgiIpcDir /tmp/fcgi_ipc FastCgiServer /usr/local/apache2/htdocs/test/public/dispatch.fcgi \ -initial-env RAILS_ENV=development \ -idle-timeout 60

ll /usr/local/apache2/modules
total 272
-rw-r–r-- 1 zwilliam users 8904 May 19 09:52 httpd.exp
-rwxr-xr-x 1 root root 179916 May 19 09:59 mod_fastcgi.so
-rwxr-xr-x 1 root root 74577 May 19 10:25 mod_fcgid.so

ll /usr/local/apache2/htdocs/test/public/dispatch.fcgi
-rwxr-xr-x 1 zwilliam apache 901 May 19 11:21
/usr/local/apache2/htdocs/test/public/dispatch.fcgi

General Apache options

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

If you don’t want Rails to look in certain directories,

use the following rewrite rules so that Apache won’t rewrite certain

requests

Example:

RewriteCond %{REQUEST_URI} ^/notrails.*

RewriteRule .* - [L]

Redirect all requests not available on the filesystem to Rails

By default the cgi dispatcher is used which is very slow

For better performance replace the dispatcher with the fastcgi one

Example:

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

RewriteEngine On

If your Rails application is accessed via an Alias directive,

then you MUST also set the RewriteBase in this htaccess file.

Example:

Alias /myrailsapp /path/to/myrailsapp/public

RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

In case Rails experiences terminal errors

Instead of displaying this message you can supply a file here which

will be rendered instead

Example:

ErrorDocument 500 /500.html

ErrorDocument 500 “

Application error

Rails application failed to
start properly”

Brian H. wrote:

  1. Ensure FastCGIServer is set up in your httpd.conf file to point to
    your dispatch.fcgi file
  2. Ensure that FastCGI module is loaded
  3. Ensure that dispatch.fcgi has execuite privileges enabled for your
    web user
  4. Ensure that your .htaccess file is directing requests to
    dispatch.fcgi

#4

I am not sure what the shebang line is. Could you elaborate? Here is my
dispatch.fcgi file:

#!/usr/local/bin/ruby
require File.dirname(FILE) + “/…/config/environment”
require ‘fcgi_handler’
RailsFCGIHandler.process!

Steve L. wrote:

Is the shebang line in your dispatch.fcgi file set correctly?


#5

One thing I see wrong is that you’re using FastCGI in Development mode
which is a no-no because it causes memory leaks. Apache + FCGI is for
production. Use Mongrel or WEBrick for development mode.

Shebang line is the first line of the ruby script that starts with #!
At your command prompt, type ‘which ruby’ and make sure that line 1 of
dispatch.fcgi is the same as the output you get from ‘which ruby’


#6

Is the shebang line in your dispatch.fcgi file set correctly?