mod_perl, freetds and environment variables???

ddick on 2010-03-09T09:27:20

I have a application written as CGI scripts that run under mod_perl mode via ModPerl::Registry or if anyone still uses it Apache::Registry. It also connects to a variety of databases, including Microsoft SQL Server via freetds.

Freetds can be controlled via a freetds.conf config file or environment variables.

I liked the idea of using the distros freetds libraries (actually, freetds contains the ct library, which is the only one that DBD::Sybase cares about) and i thought i could avoid the issues with me and everyone else writing to the freetds.conf file by using environment variables.

Which worked well until it ran in mod_perl

Then it died horribly

Turns out that controlling a C shared library via setting environment variables in perl is tricky in mod_perl

Just a note in case someone else tries configuring mod_perl to talk to SQL Server via environment variables

However, so long as you use the freetds.conf file, SQL Server and mod_perl get along fine... :)