FastCGI is very tricky to debug and most of the time an error is for a random reason. Here are few tips for working with FastCGI.
1. Always make sure your running in production mode by setting this in
environment.rb
2. When you switch from cgi to fastcgi, completely exit your browser
application before trying to access the site again, the reason being that the cgi and fastcgi processes cannot share session information.
3. To switch to fastcgi mode, edit the .htaccess file in railsapp/public and change dispatch.cgi to dispatch.fcgi _be sure that your dispatch.fcgi file have the correct path to ruby. The first line of the dispatch.fcgi file should be #!/usr/local/bin/ruby This is probably only a concern if you have uploaded an existing application.
Here’s an example .htaccess file:
# Not needed
#AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
4. Your permission settings are a little different for FastCGI mode vs. CGI
mode. Your /railsapp/log directory needs to be 755 so the fastcgi process can write to the fastcgi crash log. The /tmp directories (sessions, cache, and sockets) also need to be set to 755.
5. Your process will not stay running because we use dynamic fastcgi processes. If your site is not being used then apache will try and kill your processes to conserve resources in our shared environment.
6. Make sure there are no errors or warnings, this can cause problems. (? More explanation here…)
Also see How To use FastCGI For more information on using FastCGI