# Running the same application multiple times with different e

**URL:** <https://www.ruby-forum.com/t/running-the-same-application-multiple-times-with-different-e/62860>\
**Category:** Rails\
**Created:** [June 8, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/running-the-same-application-multiple-times-with-different-e/62860 "2006-06-08T20:30:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@tobias](https://www.ruby-forum.com/u/tobias)\
**Post date:** [June 8, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/running-the-same-application-multiple-times-with-different-e/62860/1 "2006-06-08T20:30:20Z")

</div>

Hi!

I have an application that needs to be run on multiple virtual hosts  
(Apache2) with each instance having it’s own environment / database.  
Using dispatch.cgi I simply configure two virtual hosts pointing to the  
same application path and just add a “SetEnv RAILS\_ENV  
\<environment\_name\>” to each virtual host section in the Apache  
configuration. But with FastCGI / dispatch.fcgi this doesn’t work.

Any ideas how to run multiple instances (each having a different  
database) of the same application with Apache and FastCGI?

Regards,

Tobias

---

<div class="post-metadata">

**Author:** ![tobias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@tobias](https://www.ruby-forum.com/u/tobias)\
**Post date:** [June 8, 2006, 8:40pm UTC](https://www.ruby-forum.com/t/running-the-same-application-multiple-times-with-different-e/62860/2 "2006-06-08T20:40:12Z")

</div>

Tobias G. wrote:

> Hi!
> 
> I have an application that needs to be run on multiple virtual hosts  
> (Apache2) with each instance having it’s own environment / database.  
> Using dispatch.cgi I simply configure two virtual hosts pointing to the  
> same application path and just add a “SetEnv RAILS\_ENV  
> \<environment\_name\>” to each virtual host section in the Apache  
> configuration. But with FastCGI / dispatch.fcgi this doesn’t work.
> 
> Any ideas how to run multiple instances (each having a different  
> database) of the same application with Apache and FastCGI?
> 
> Regards,
> 
> Tobias

I am doing something similar, but with lighttpd. Rails automatically  
handles different environments with different databases. Just set them  
up in database.yml.

The basic config looks like:

$HTTP[“host”] == “[www.mydomain.com](http://www.mydomain.com)” {  
server.document-root = “/home/mydomain/public/”  
fastcgi.server = (  
“.fcgi” =\>  
( “localhost” =\>  
(  
“socket” =\>  
“/home/lighttpd/var/run/lighttpd-fcgi-mwprod.socket”,  
“bin-path” =\> “/home/magneticworld/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “production” ),  
“max-load-per-proc” =\> 25,  
“min-procs” =\> 1,  
“max-procs” =\> 4,  
“idle-timeout” =\> 30  
)  
)  
)  
}

$HTTP[“host”] == “[dev.mydomain.com](http://dev.mydomain.com)” {  
server.document-root = “/home/mydomain/public/”  
fastcgi.server = (  
“.fcgi” =\>  
( “localhost” =\>  
(  
“socket” =\>  
“/home/lighttpd/var/run/lighttpd-fcgi-mwdev.socket”,  
“bin-path” =\> “/home/magneticworld/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “development” ),  
“max-load-per-proc” =\> 25,  
“min-procs” =\> 1,  
“max-procs” =\> 4,  
“idle-timeout” =\> 30  
)  
)  
)  
}

2 sites, 2 environments, 2 dbs, running from the same root.

---

<div class="post-metadata">

**Author:** ![tobias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@tobias](https://www.ruby-forum.com/u/tobias)\
**Post date:** [June 9, 2006, 12:33am UTC](https://www.ruby-forum.com/t/running-the-same-application-multiple-times-with-different-e/62860/3 "2006-06-09T00:33:28Z")

</div>

Alex W. wrote:

> 2 sites, 2 environments, 2 dbs, running from the same root.

Thanks! That’s exactly what I want to do. It’s just, that I want to do  
it with Apache2. It seems I can’t set different fcgi servers with  
different environments for each virtual host in Apache.

No Apache-Rails-Guru around?

Tobias
