# More fcgi problems

**URL:** <https://www.ruby-forum.com/t/more-fcgi-problems/61065>\
**Category:** Rails\
**Created:** [May 19, 2006, 7:44pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065 "2006-05-19T19:44:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [May 19, 2006, 7:44pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065/1 "2006-05-19T19:44:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [May 19, 2006, 8:55pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065/2 "2006-05-19T20:55:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [May 19, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065/3 "2006-05-19T21:08:11Z")

</div>

Does you see anything wrong with any of this?

1. 

 FastCgiIpcDir /tmp/fcgi\_ipc FastCgiServer /usr/local/apache2/htdocs/test/public/dispatch.fcgi \ -initial-env RAILS\_ENV=development \ -idle-timeout 60
1. 

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

1. 

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

1. 

# 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

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [May 19, 2006, 10:24pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065/4 "2006-05-19T22:24:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [May 21, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065/5 "2006-05-21T17:52:56Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [May 19, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/more-fcgi-problems/61065/6 "2006-05-19T22:19:36Z")

</div>

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