Troubleshooting mod_perl problems
Frequently encountered problems (warnings and fatal errors) and their troubleshooting.
Update DBI to at least version 1.31.
%ENV
For example some people have reported problems with DBD::Oracle (whose guts are implemented in C), which doesn't see environment variables (like ORACLE_HOME, ORACLE_SID, etc.) set in the perl script and therefore fails to connect.
DBD::Oracle
ORACLE_HOME
ORACLE_SID
The issue is that the C array environ[] is not thread-safe. Therefore mod_perl 2.0 unties %ENV from the underlying environ[] array under the perl-script handler.
environ[]
The DBD::Oracle driver or client library uses getenv() (which fetches from the environ[] array). When %ENV is untied from environ[], Perl code will see %ENV changes, but C code will not.
getenv()
The modperl handler does not untie %ENV from environ[]. Still one should avoid setting %ENV values whenever possible. And if it is required, should be done at startup time.
In the particular case of the DBD:: drivers, you can set the variables that don't change ($ENV{ORACLE_HOME} and $ENV{NLS_LANG} in the startup file, and those that change pass via the connect() method, e.g.:
DBD::
$ENV{ORACLE_HOME}
$ENV{NLS_LANG}
connect()
my $sid = 'ynt0'; my $dsn = 'dbi:Oracle:'; my $user = 'username/password'; my $password = ''; $dbh = DBI->connect("$dsn$sid", $user, $password) or die "Cannot connect: " . $DBI::errstr;
Also remember that DBD::Oracle requires that ORACLE_HOME (and any other stuff like NSL_LANG stuff) be in %ENV when DBD::Oracle is loaded (which might happen indirectly via the DBI module. Therefore you need to make sure that wherever that load happens %ENV is properly set by that time.
DBI
You need to install at least version 2.87 of CGI.pm to work under mod_perl 2.0, as earlier CGI.pm versions aren't mod_perl 2.0 aware.
Maintainer is the person(s) you should contact with updates, corrections and patches.
Stas Bekman
Only the major authors are listed above. For contributors see the Changes file.
To install mod_perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm mod_perl
CPAN shell
perl -MCPAN -e shell install mod_perl
For more information on module installation, please visit the detailed CPAN module installation guide.