Ruby, FastCGI and Virtualhosts
Now that that MadPilot Productions site is live, I wanted to run FastCGI. Even though the site is relatively low traffic, I was intrigued to see whether the speedup would be noticable. It is. Unfortunately, the literature I have seen hasn’t really made it clear how to set this up on a server that runs virtualhosts, so here is how it works.
To make a ruby on rails site run in production mode you need to add the following line to the apache.conf file:
FastCgiServer /path/to/site/public/dispatch.fcgi -initial-env RAILS_ENV=production -processes 15 -idle-timeout 60
However, putting this between VirtualHost tags fails. The solution is simple really – put it OUTSIDE the VirtualHost tag. You can have multiple entries in the config file. Since I split my virtual hosts into seperate files (ala Debian, even though I run a Gentoo server) I just drop it in bottom on the file below the closing VirtaulHost tag.
As an aside – Gentoo has a slight problem in that there may throw an error about User/Groups when starting. To fix, put the lines
User apache
Group apache
before the FastCgiIpcDir /tmp/fcgi_ipc directive in the [number]_mod_fastcgi.conf file that is located in /etc/apache/modules.d/ directory.