Rails Environments as Virtual Hosts
The problem is to pass an environment variable from the virtual host to the fastcgi dispatcher. This is normally done by the -initial-env parameter of the FastCgiConfig statement. Unfortunately this statement is only allowed in the server config, not in the virtual host context.
In the mod_fastcgi documentation i found: "To pass a variable from the Apache environment, don't provide the "=" ...".
So i configuerd -initial-env RAILS_ENV
in the global FastCgiConfig statement and standard mod_env's
SetEnv RAILS_ENV developemnt
in the virtual host.
Since the fastcgi-processes are started with suexec in a different security context, i also had to hack suexec.c to allow the RAILS_ENV variable.
Inspite all hacking the variable did not pass to the dispatcher. After 3 hours i finally gave up. It seems to be impossible to have a dynamic setup like this.
The only dynamic information which can be passed from apaches virtual host configuration to the fastcgi process is the path of the fastcgi program itself. So i examined rubys __FILE__ variable and matched a specific part of it to determine the actual environment. This was the way out of the dilemma.