# Deploying multiple Rails apps with FastCGI

**URL:** <https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510>\
**Category:** Rails\
**Created:** [October 9, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510 "2006-10-09T16:33:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 9, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/1 "2006-10-09T16:33:39Z")

</div>

Hi all,

“Agile Web D. with Ruby on Rails” describes the setup for  
Apache 1.x with mod\_fastcgi etc. but the example contains only the  
config for ONE Rails application. How do I run multiple Rails apps on  
the same server using fcgi?

Regards,  
Robert

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 9, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/2 "2006-10-09T19:20:41Z")

</div>

Robert S. wrote:

> Hi all,
> 
> “Agile Web D. with Ruby on Rails” describes the setup for  
> Apache 1.x with mod\_fastcgi etc. but the example contains only the  
> config for ONE Rails application. How do I run multiple Rails apps on  
> the same server using fcgi?

Are you having any luck with ONE rails application with apache+fcgi? I  
had no end of trouble getting that to work reliably. And that seems to  
be the experience that a lot of people have. If you can’t switch to  
lighttpd+fcgi, I’d recommend using mongrel or SCGI with apache.

-matthew

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 9, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/3 "2006-10-09T19:27:58Z")

</div>

I’m still trying, actually, I follow the instructions in the book 🙂  
Will research your alternatives though. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 10, 2006, 2:59am UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/4 "2006-10-10T02:59:18Z")

</div>

I had minor issues getting an app running with apache+fcgi, mostly just  
deployment stuff: shebang lines were wrong in the dispatch.\* files, file  
permissions were wrong on those files after deployment, etc. Since I  
got my  
deploy script fine-tuned there haven’t been any problems.

My app is for a single client, load is about 50 users per day, and fcgi  
handles it fine.

– foobario

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 10, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/5 "2006-10-10T22:47:07Z")

</div>

I have done this with Apache 2. I’m writing a guide on setting up  
fastCGI or SCGI on Windows XP. If that is your OS then maybe it will  
help:

[http://www.writely.com/View?docid=acj4fmm2gr83\_3gx8pf2&revision=acj4fmm2gr83\_3gx8pf2:302](http://www.writely.com/View?docid=acj4fmm2gr83_3gx8pf2&revision=acj4fmm2gr83_3gx8pf2:302)

If not I have many links listed at the end for sites detailing how to  
setup these dispatchers.

I might be able to help with a specific question on the setup. If you  
have any suggestions on improving my guide let me know 🙂

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 11, 2006, 1:24am UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/6 "2006-10-11T01:24:33Z")

</div>

Oops, forgot a few lines at the very top:

# Set the public directory for the production application,

# which is the default for this domain.

server.document-root = “/usr/local/bin/production/public”  
server.error-handler-404 = “/dispatch.fcgi”

# Set up a separate virtual host for the training app.

# We have a separate subdomain, ‘training’, to catch

# requests for this app. Set a different application path

# for this app, and copy dispatch.fcgi to training.fcgi in

# its public directory.

$HTTP[“host”] =~ “training.yourcompany.org” {  
server.document-root = “/usr/local/bin/training/public”  
server.error-handler-404 = “/training.fcgi”  
}

# Set up the FCGI servers. First the training app; then

# everything else falls through to the production app.

fastcgi.server = (  
“/training” =\>  
( “localhost-7100” =\> ( “host” =\> “127.0.0.1”, “port” =\> 7100,  
“bin-environment” =\> (“RAILS\_ENV” =\> “training”) ),  
“localhost-7101” =\> ( “host” =\> “127.0.0.1”, “port” =\> 7101,  
“bin-environment” =\> (“RAILS\_ENV” =\> “training”) ) ),  
“.fcgi” =\>  
( “localhost-7000” =\> ( “host” =\> “127.0.0.1”, “port” =\> 7000,  
“bin-environment” =\> (“RAILS\_ENV” =\> “production”) ),  
“localhost-7001” =\> ( “host” =\> “127.0.0.1”, “port” =\> 7001,  
“bin-environment” =\> (“RAILS\_ENV” =\> “production”) ) )  
)

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [October 11, 2006, 1:18am UTC](https://www.ruby-forum.com/t/deploying-multiple-rails-apps-with-fastcgi/71510/7 "2006-10-11T01:18:30Z")

</div>

Robert S. wrote:

> Hi all,
> 
> “Agile Web D. with Ruby on Rails” describes the setup for  
> Apache 1.x with mod\_fastcgi etc. but the example contains only the  
> config for ONE Rails application. How do I run multiple Rails apps on  
> the same server using fcgi?
> 
> Regards,  
> Robert

I realize you want a way to do this in Apache, but we’re a Lighttpd  
shop. Maybe our Lighttpd configuration can point you in the right  
direction however. And help anyone else reading this who’s wondering how  
to do it in Lighty.

We have two apps running on the same box, a production app and a  
training app. Here’s the relevant stuff cut out of lighttpd.conf:

# Set up a separate virtual host for the training app. We have a

separate

# subdomain, ‘training’, to catch requests for this app.

$HTTP[“host”] =~ “training.yourcompany.org” {  
server.document-root = “/usr/local/bin/training/public”  
server.error-handler-404 = “/training.fcgi”  
}

# Set up the FCGI servers. First the training app; then everything else

# falls through to the production app.

fastcgi.server = (  
“/training” =\>  
( “localhost-7100” =\> ( “host” =\> “127.0.0.1”, “port” =\>  
7100,  
“bin-environment” =\> (“RAILS\_ENV” =\> “training”)  
),  
“localhost-7101” =\> ( “host” =\> “127.0.0.1”, “port” =\>  
7101,  
“bin-environment” =\> (“RAILS\_ENV” =\> “training”)  
) ),  
“.fcgi” =\>  
( “localhost-7000” =\> ( “host” =\> “127.0.0.1”, “port” =\>  
7000,  
“bin-environment” =\> (“RAILS\_ENV” =\>  
“production”) ),  
“localhost-7001” =\> ( “host” =\> “127.0.0.1”, “port” =\>  
7001,  
“bin-environment” =\> (“RAILS\_ENV” =\>  
“production”) ) )  
)
