Gossamer Forum
Home : Gossamer Threads Inc. : Announcements :

Guidelines for loading multiple programs under mod_perl

Quote Reply
Guidelines for loading multiple programs under mod_perl
Because there have been no specific instructions regarding how to set up multiple programs under mod_perl, and because it can be difficult to get working properly, I've written this post to assist people attempting to set it up. I'll use an example of loading Links SQL 2.1.2, Gossamer Mail 2.2.2, GForum 1.2.2, and Community 1.0.1 under the same mod_perl server.

The critical thing is to make sure that the most recently released program is loaded first in your mod_perl startup file. Of the example programs mentioned above, Gossamer Forum 1.2.2 and Gossamer Mail 2.2.2 were released at the same time, both after Community 1.0.1, which was released after Links SQL 2.1.2. So, the order we'll use is: GMail -> GForum -> Community -> Links SQL. If Community 1.0.2 was released (and no new versions of other programs), the order would change to Community -> GMail -> GForum -> Links SQL. A new Links SQL release after that would change the order to Links SQL -> Community -> GMail -> GForum, and so on.

I should point out that it is not possible to run different versions of the same product under mod_perl - specifically, you cannot have both Links SQL 2.1.2 and 2.2.0 under the same mod_perl installation. Multiple installations of the same version - in other words, multiple 2.1.2 installations or multiple 2.2.0 installations - are okay.

To ensure that the library paths are searched in the correct order, you should combine all the "use lib" lines into a single command, ordered appropriately from newest to eldest program library path:

Code:
use lib
'/path/to/gmail/admin',
'/path/to/gforum/admin',
'/path/to/community/private/lib',
'/path/to/linkssql/admin';

Following this, you want to load each program's mod_perl file:

Code:
use Links::mod_perl;
use GMail::mod_perl;
use Community::mod_perl;
use GForum::mod_perl;

Note that the above calls are _not_ in any particular order - the order of these calls is not important, it is only the 'use lib' command above that needs to specify the program library paths in the correct order.

A common mistake is in using a configuration such as:

Code:
use lib '/path/to/gmail/admin';
use GMail::mod_perl;

use lib '/path/to/gforum/admin';
use GForum::mod_perl;

use lib '/path/to/community/private/lib';
use Community::mod_perl;

use lib '/path/to/linkssql/admin';
use Links::mod_perl;
Although this configuration would _appear_ to work, it can lead to problems because each call to 'use lib' adds the path to the beginning of the search path - so you actually end up with a path order opposite to what you want. Most of the mod_perl.pm files have a few omissions - typically, modules that are very rarely used (or, sometimes, due to a mistake on our part). So, when one of these modules is loaded, it would end up being loaded from the Links SQL version of the library, which may be missing new features that Gossamer Mail depends on. Reversing this order would make things worse, because then you'd be purposely loading older versions of modules into the mod_perl server before newer versions.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com

Last edited by:

Jagerman: Jun 23, 2004, 2:31 PM