Deploying multiple Rails apps with FastCGI

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

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

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

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

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

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 :slight_smile:

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”) ) )
)

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”) ) )
)