title: Custom Perl Modules on Apache2 Server
body: <p>Currently I am trying to use a bunch of custom perl modules, test.pm as one of them, within my Perl program with a WebUI. I am running it on a Windows 7 machine with Apache2 installed. When I run the program in cmd prompt by using perl test.pl, the program runs fine. However running it on Apache gives me this error.</p>
  
  <pre><code>[Wed Jun 13 16:23:32 2012] [error] [client 127.0.0.1] Can't locate test.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at C:/www/hello2.pl line 7.\r, referer: http://localhost/ui_test.htm
  [Wed Jun 13 16:23:32 2012] [error] [client 127.0.0.1] BEGIN failed--compilation aborted at C:/www/hello2.pl line 7.\r, referer: http://localhost/ui_test.htm
  </code></pre>
  
  <p>I have used:</p>
  
  <pre><code>foreach $key (sort keys(%ENV)) {
    print "$key = $ENV{$key}&lt;p&gt; \n";
  }
  </code></pre>
  
  <p>and under the path variable, I do see the folder of where all the modules are located. Is there somewhere else I should use to add to the Perl Path?</p>
  
  <p>In addition adding use lib "C:\testpm\"; to my code only changes the @INC to </p>
  
  <pre><code>(@INC contains: C:\testpm\ C:/Perl/lib C:/Perl/site/lib .)
  </code></pre>
  
  <p>Is there something additional you need to do to add paths to run custom perl modules on an apache server?</p>
  
  <p><strong>Solution Based On Answer:</strong>
  I found this to work the best. Within my httpd-perl.conf file, I added these lines:</p>
  
  <pre><code>&lt;IfModule env_module&gt;
      SetEnv PERL5LIB "C:\testpm;C:\testpm1;"
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>(extended out with C:\testpm1 to show people with similar questions how to add even more module folders.)</p>