We help IT Professionals succeed at work.
Get Started

Apache environment variables not working in CGI

James Talvy
James Talvy asked
Last Modified: 2015-03-03
I am trying to run a Perl CGI on Apache and it is complaining with the following:

[Tue Feb 24 14:42:43 2015] Can't load '/usr/local/lib64/perl5/auto/DBD/Sybase/Sybase.so' for module DBD::Sybase: libsybct64.so: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 200.\n at /home/gsg/gsg/jt.pl line 4\nCompilation failed in require at /home/gsg/gsg/jt.pl line 4.\nBEGIN failed--compilation aborted at /home/gsg/gsg/jt.pl line 4.\n

I know this is somehow related to the LD_LIBRARY_PATH not being set since I get the same error on the comand line with the following small Perl script:

     #!/usr/local/bin/perl -w
     use DBD::Sybase;

When I set the LD_LIBRARY_PATH to where the sybase libraries are I no longer get an error on the command line.

I set the env variables in the httpd.conf config file via:

   SetEnv SYBASE /appl/sybase
   SetEnv SYBASE_OCS OCS-15_0
   SetEnv LD_LIBRARY_PATH /appl/sybase/OCS-15_0/lib

If I make a small CGI that prints the environment it does show that I have SYBASE, SYBASE_OCS & LD_LIBRARY_PATH set:

   #!/usr/local/bin/perl -w
   use CGI;
   my $q = CGI->new;
   print $q->header, $q->start_html ;

   print "<TABLE>\n" ;
   foreach $key (sort keys(%ENV))
     print "<TR><TD>$key</TD><TD>$ENV{$key}</TD></TR>\n" ;
   print "</TABLE>\n" ;

   print $q->end_html;

If I force the system as a whole to find the Sybase libs by putting the path to it in /etc/ld.so.conf.d/ it doesn't help since then the CGI fails since it is complaining it does not know the SYBASE & SYBASE_OCS env variables; even though they display in the test CGI above.
Apache Version:
   Apache/2.2.15 (Unix) DAV/2 mod_perl/2.0.4 Perl/v5.10.1 configured

uname -a:
   Linux devtest002 2.6.32-431.29.2.el6.x86_64 #1 SMP Sun Jul 27 15:55:46 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

I appreciate any help you can provide to resolve this.
Watch Question
This problem has been solved!
Unlock 1 Answer and 31 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE