# Can't get Fast CGI working

**URL:** <https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432>\
**Category:** Rails\
**Created:** [March 4, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432 "2006-03-04T20:21:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mendake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@mendake](https://www.ruby-forum.com/u/mendake)\
**Post date:** [March 4, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432/1 "2006-03-04T20:21:11Z")

</div>

Well, after many hours of tinkering and internet browsing I just can’t  
get Fast CGI to work with Rails and Apache 1.3 on FreeBSD 5.4 Normal CGI  
works fine, but as soon as I enable FastCGI in .htaccess I get the  
message:

Application error  
Rails application failed to start properly

Here’s what I’ve done so far:

- I’ve installed all the necessary software for rails and fast cgi.

- FastCGI does seem to be configured correctly in the apache config  
file. I’ve added the necessary virtual host settings and other apache  
directives, as per the instructions on the Rails wiki.

- In .htaccess I changed

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

to

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

- Cleared out rails related temporary files from /tmp.

- I’ve restarted apache.

- I’ve restarted my browser.

- I’ve made sure dispatch.fcgi contains the line “require  
‘fcgi\_handler’” (without quotes, of course).

- I set the /log directory permissions to 755. Heck, I even set the  
entire rails directory to 777 (it’s on a local intranet, so security  
isn’t a big issue right now).

But despite my best efforts I’m not getting any love from rails and fast  
cgi, and I’m completely stuck. Any help would be GREATLY appreciated.

---

<div class="post-metadata">

**Author:** ![mendake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@mendake](https://www.ruby-forum.com/u/mendake)\
**Post date:** [March 4, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432/2 "2006-03-04T22:13:39Z")

</div>

I experienced the (approximately, I’m using Apache 2.x) same problems.  
To keep a long story short, I’m using Lighttpd now. The long story is  
here: [http://www.mindshards.net/?p=15](http://www.mindshards.net/?p=15) amongst others. In the end Apache  
did work but still unsatisfactory. Rails developers should _really_  
start supporting Apache for real.  
From a glace at your post I’d same you need to point to your fcgi  
server.

MenDAKE wrote:

> Well, after many hours of tinkering and internet browsing I just can’t  
> get Fast CGI to work with Rails and Apache 1.3 on FreeBSD 5.4 Normal CGI  
> works fine, but as soon as I enable FastCGI in .htaccess I get the  
> message:
> 
> Application error  
> Rails application failed to start properly
> 
> Here’s what I’ve done so far:
> 
> - I’ve installed all the necessary software for rails and fast cgi.
> 
> - FastCGI does seem to be configured correctly in the apache config  
> file. I’ve added the necessary virtual host settings and other apache  
> directives, as per the instructions on the Rails wiki.
> 
> - In .htaccess I changed
> 
> RewriteRule ^(.\*)$ dispatch.cgi [QSA,L]
> 
> to
> 
> RewriteRule ^(.\*)$ dispatch.fcgi [QSA,L]
> 
> - Cleared out rails related temporary files from /tmp.
> 
> - I’ve restarted apache.
> 
> - I’ve restarted my browser.
> 
> - I’ve made sure dispatch.fcgi contains the line “require  
> ‘fcgi\_handler’” (without quotes, of course).
> 
> - I set the /log directory permissions to 755. Heck, I even set the  
> entire rails directory to 777 (it’s on a local intranet, so security  
> isn’t a big issue right now).
> 
> But despite my best efforts I’m not getting any love from rails and fast  
> cgi, and I’m completely stuck. Any help would be GREATLY appreciated.

---

<div class="post-metadata">

**Author:** ![mendake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@mendake](https://www.ruby-forum.com/u/mendake)\
**Post date:** [March 5, 2006, 3:08am UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432/3 "2006-03-05T03:08:28Z")

</div>

Thanks for the response, Anon. What do you mean about needing to point  
to my fcgi server?

---

<div class="post-metadata">

**Author:** ![mendake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@mendake](https://www.ruby-forum.com/u/mendake)\
**Post date:** [March 5, 2006, 1:33pm UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432/4 "2006-03-05T13:33:34Z")

</div>

Am Samstag, den 04.03.2006, 20:21 +0100 schrieb MenDAKE:

> But despite my best efforts I’m not getting any love from rails and fast  
> cgi, and I’m completely stuck. Any help would be GREATLY appreciated.

Call

ruby public/dispatch.fcgi

## from your Rails root directory and see if some exceptions appear.

Norman T.

[http://blog.inlet-media.de](http://blog.inlet-media.de)

---

<div class="post-metadata">

**Author:** ![mendake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@mendake](https://www.ruby-forum.com/u/mendake)\
**Post date:** [March 5, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432/5 "2006-03-05T18:57:03Z")

</div>

Well I run apache2 and have this file  
/etc/apache2/mod-available/fastcgi.conf which is something like a  
httpd.conf exerpt. In there I have:  
AddHandler fastcgi-script .fcgi  
FastCgiIpcDir /var/lib/apache2/fastcgi  
FastCgiServer /path/to/your/apps/public/dispatch.fcgi -processes 2  
-idle-timeout 60

Which points to your fastcgi server.

MenDAKE wrote:

> Thanks for the response, Anon. What do you mean about needing to point  
> to my fcgi server?

---

<div class="post-metadata">

**Author:** ![mendake](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@mendake](https://www.ruby-forum.com/u/mendake)\
**Post date:** [March 6, 2006, 10:37pm UTC](https://www.ruby-forum.com/t/cant-get-fast-cgi-working/54432/6 "2006-03-06T22:37:48Z")

</div>

anon wrote:

> Well I run apache2 and have this file  
> /etc/apache2/mod-available/fastcgi.conf which is something like a  
> httpd.conf exerpt. In there I have:  
> AddHandler fastcgi-script .fcgi  
> FastCgiIpcDir /var/lib/apache2/fastcgi  
> FastCgiServer /path/to/your/apps/public/dispatch.fcgi -processes 2  
> -idle-timeout 60
> 
> Which points to your fastcgi server.
> 
> MenDAKE wrote:
> 
> > Thanks for the response, Anon. What do you mean about needing to point  
> > to my fcgi server?

That was it! I never read anywhere that the above lines need to be added  
to the apache file, but that completely fixed my problem. Rails is now  
blazingly fast. Thank you VERY much for your help.
