Using mod_fcgid for Ruby on Rails Applications
Many people know about the old school mod_fastcgi, but very few know about mod_fcgid. To put it extremely briefly, if you are using Apache 2, and you should be, you should be using mod_fcgid, and not mod_fastcgi.
Here quick guide on how to configure mod_fcgid for use with Apache HTTPD 2.2.0 and Typo, a RoR blog engine:
- Download and Prepare mod_fcgid:
wget http://fastcgi.coremail.cn/mod_fcgid.1.07.tar.gz
tar -xvzf mod_fcgid.1.07.tar.gz
cd mod_fcgid.1.07 - Edit the Makefile. Change the top_dir variable to the prefix of your Apache 2 install.
- Apply this patch for mod_fcgid:
wget http://constant.northnitch.com/~chip/mod_fcgid.1.07-apache2.2.0.patch patch -p0 < mod_fcgid.1.07-apache2.2.0.patch
This patch has been submitted upstream, and should be part of the next release.
- Run ‘make’.
- Copy .libs/mod_fcgid.so to your Apache modules directory
- Add the following to your httpd.conf, to load the module:
LoadModule fcgid_module modules/mod_fcgid.so IPCCommTimeout 40 IPCConnectTimeout 10
- Configure mod_fcgid for your Rails Application:
<VirtualHost *:80> ... # Insert the rest of your vhost config here. ServerName foo.example.com <Location /journal> RewriteEngine On # Let apache handle purely static files like images by itself. RewriteCond %{REQUEST_FILENAME} !-f # Send Everything else to Typo RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </Location> <Directory /sites/foo.example.com/public_html/journal> # ExecCGI is required for mod_fcgid to work. Options Indexes FollowSymLinks ExecCGI # Disable .htaccess files. AllowOverride None Order allow,deny Allow from all # This tells mod_fcgid to run the dispatch.fcgi script as a FastCGI AddHandler fcgid-script .fcgi </Directory> .... </VirtualHost> - Thats it.
This whole process can be easier, since mod_fcgid is also in many packaging systems, including FreeBSD’s Ports, and Gentoo Portage.
January 3rd, 2006 at 11:44 am
It appears to be in ubuntu as well:
January 5th, 2006 at 10:55 pm
Do you have windows instructions?
January 8th, 2006 at 4:21 am
Ken,
use *nix
January 23rd, 2006 at 10:17 pm
That’s great! Thanks!
I’ve published some slighly modified instructions on my blog so that you can still use the .htaccess file.
Now we play the waiting game to see if the zombie problem is fixed
- Myles
January 25th, 2006 at 11:23 am
The one thing I’ve found disappointing about mod_fcgid is that there doesn’t seem to be any way to have it prefork copies of the application. This means that first request can be very, very slow.
February 5th, 2006 at 12:14 pm
Thank you very much.
I solved my problem.
I wrote this solution in japanese.
February 6th, 2006 at 9:44 am
Don’t be tempted to go for version 1.0.8 - for me it resulted in a log full of segfaults. 1.0.7 works a treat!
February 7th, 2006 at 3:54 pm
Yeah, it’s really irritating that there’s no way to specify static FastCGIs with mod_fcgid.