[Catalyst] Configuration based on hostname

Kieren Diment diment at gmail.com
Sun Jul 12 07:54:09 GMT 2009

On 12/07/2009, at 5:29 PM, Mihai Bazon wrote:

> Kieren Diment <diment at gmail.com> wrote:
>> On 12/07/2009, at 4:35 PM, Mihai Bazon wrote:
>>> Hi folks,
>>> I think this was raised before but I don't remember to have seen a
>>> satisfactory answer.  Someone please point me into the right
>>> direction.
>>> I want to deploy a Catalyst app that will be used to serve multiple
>>> websites.  The platform will be Apache2 (prefork) + mod_perl2.  I  
>>> want
>>> Catalyst to read a different configuration file, based on the host
>>> name.
>>> Each virtual host will have its own database (configured in .conf)  
>>> and
>>> its own "root" directory, but other than this, all the Perl modules
>>> are
>>> the same.
>>> I know this can be done with FastCGI by launching a different  
>>> process
>>> for each host, but I'm interested in a mod_perl solution.  Is it
>>> feasible?
>> One of the limitations of mod_perl is that you can't run the same app
>> more than once on the same server.  Sorry.
> Let me clarify that.  I don't want to run the app more than once.  I
> just want the application to switch configuration file and database
> depending on the hostname that each particular request targets.
> I've done this a zillion times with plain mod_perl, I just don't know
> what's the proper route with Catalyst.

Possibly to pick up some particular config that's chosen on the basis  
of the value of $c->req->host?

$c->config( host_config => {example.com => [qw/foo bar/],
                                                   superbad.com => [qw/ 
fred wilma/}

Or if you need something more dynamic, put some configuration grabbing  
routine in auto in Controller::Root.

More information about the Catalyst mailing list