Japhering has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to replicate a development environment with the following components:

Ubuntu 9.10
Apache2 2.2.12
mod_perl2 2.0.4

and a perl based portal package

Metadot 6.4.5.3

Metadot code sits outside of the installed %INC paths.

In theory, I should be able to set and export PERL5LIB in the root shell before starting Apache2 and have the contents added to %INC.

When I set PERL5LIB and run perl -V in the root shell, I see that %INC has been appropriately modified.

I verify that there are NO Apache instances running. Check to make sure PERL5LIB is set as desired in the root shell environment. Then I start Apache.

The first page I hit that calls a Metadot routine errors out with a "Can't locate Metadot.pm in @INC ..." message where the displayed %INC does not include the contents of PERL5LIB.

It works fine on the production RH server, just not on my development machine.

Anyone have any ideas of what I might be doing wrong?

Thanks

Replies are listed 'Best First'.
Re: changing mod_perl's version of %INC
by almut (Canon) on Mar 17, 2010 at 22:13 UTC

    As already said, using PerlSwitches is likely the easiest method, but if you wanted to keep using PERL5LIB, PerlPassEnv should help (Apache, or rather the respective modules such as mod_cgi, mod_fastcgi, mod_perl, clean the environment, so you have to explicitly pass environment variables here).

    (BTW, you should generally be able to set apache-wide environment variables in /etc/apache2/envvars, which is being sourced from the startup script (/usr/sbin/apache2ctl) — this way you wouldn't need to set them in your root shell.)

Re: changing mod_perl's version of %INC
by WizardOfUz (Friar) on Mar 17, 2010 at 21:57 UTC

    Have you tried:

    PerlSwitches -I /path/to/my/lib
Re: changing mod_perl's version of %INC
by ikegami (Patriarch) on Mar 17, 2010 at 22:06 UTC

    In theory, I should be able to set and export PERL5LIB in the root shell before starting Apache2 and have the contents added to %INC.

    Your use of "the root shell" instead of "a root shell" is making me think you ran a shell as root, set some environment variable, and figured it would be available to all processes running as root. It will only be available to children of that shell process.

    Either way, I'm certain that mod_perl can be configured in this respect via the Apache config files.

Re: changing mod_perl's version of %INC
by rowdog (Curate) on Mar 18, 2010 at 19:34 UTC

    When it comes to Adjusting @INC, I've always modified startup.pl to include something like

    use lib qw( /path/to/metadot /path/to/my/code );

    You said...

    Ubuntu 9.10
    Apache2 2.2.12
    mod_perl2 2.0.4
    It works fine on the production RH server, just not on my development machine.

    You can certainly develop on Ubuntu and then run it on Redhat but, along the way, you will likely encounter subtle differences in the way the different distros package their software, what version of what module is available where and such. As a bonus, problems like that can be difficult to track down.

    If you're doing more than a bit of casual programming, I'd recommend setting up a virtual server that is as similar to the production environment as you can get. If I were in your shoes, I suppose I'd use RHEL (or CentOS) in a VirtualBox and duplicate the installed software and configuration of the server.