Search code examples
apachecatalystmod-perl

Running multiple Catalyst apps through Apache


I have a suse box that holds three Catalyst apps. Ultimately I need to run all three (which in itself is not a problem, each has a different port) through Apache with mod_perl and SSL. I have successfully gotten to the point of firing up one Catalyst app and then having a successful transition to the Catalyst server.

In case anyone needs a GREAT step by step on how to do this, you can see it here. http://www.catalystframework.org/calendar/2005/7

I'm not an Apache expert, but the problem is that I am not aware that there is a way to run multiple Catalyst apps on one server and have Apache to somehow be able to serve up all three.

The page at http://www.catalystframework.org/calendar/2005/7 even says as much.....

Cons
Cannot run multiple versions of the same app
It is not possible to run two different versions of the same application in the same Apache instance because the namespaces will collide.

That being said, is this possible through multiple instances of Apache? Somehow? Through virtual hosts directives maybe? I know that by pre-loading the Catalyst app into Apache that it's going to take up huge memory each time I do that.


Solution

  • OK! I have found the answer. You can indeed run more than one Catalyst app via Apache/mod_perl, you just can't run the more than one instance of the same app. That being said, here's all you have to do run more than one (without the use of VirtualHost directives). In your default-server.conf

    PerlSwitches -I/home/me/catalyst/App1/lib
    PerlSwitches -I/home/me/catalyst/App2/lib
    
    PerlModule App1
    PerlModule App2
    
    <Location /app1>
            SetHandler modperl
            PerlResponseHandler App1
    </Location>
    
    <Location /app2>
            SetHandler modperl
            PerlResponseHandler App2
    </Location>
    

    Apache pulls in the entire Catalyst app into memory and then treats it as a handler. Only downside is that it eats memory having more than one app like this in memory. Upside is speed and that mod_perl will share the modules needed for both.

    Hopefully this will help if you're having the same issue. Also, Apache/mod_perl and your Catalyst apps must be compiled under the same version of Perl or you're going to get "undefined symbol" errors.