SCGI is a project aiming to replace CGI and FastCGI with a simpler protocol.
I just integrated Zed Shaw’s SCGI Rails Runner into a Rails project I’m working on. Documentation on integrating with Apache2, which I’m using, is still somewhat non-existing, so here are the steps it took me to get things up and running on Debian Sarge:
install apache development libraries
apt-get install apache2-threaded-dev
- get the latest SCGI module source and unpack it. Didn’t try the module contained in Sarge, as it is rather old (Version 1.2 being about a year old)
build and install the Apache module using apxs:
apxs2 -i -c mod_scgi.c
create a virtual host configuration for your application:
AddDefaultCharset utf-8 ServerName www.yourdomain DocumentRoot /your-switchtower-root/current/public ErrorDocument 500 /500.html ErrorDocument 404 /404.html # handle all requests throug SCGI SCGIMount / 127.0.0.1:9999 # matches locations with a dot following at least one more characters, that is, things like *,html, *.css, *.js, which should be delivered directly from the filesystem <LocationMatch \..+$> # don't handle those with SCGI SCGIHandler Off <Directory /your-switchtower-root/current/public/> Options +FollowSymLinks Order allow,deny allow from all
as all necessary configuration is done in the virtual host config, you can safely remove the .htaccess file inside the public directory of your Rails application. Also you can remove all dispatch.* handlers inside public.
enable the virtual host and restart Apache after that.
copy the scgi_rails script to the script directory of your rails app. Run
script/scgi_rails helpfor usage instructions