List:Bugs« Previous MessageNext Message »
From:Larry Morley Date:February 16 2000 5:57am
Subject:Using mySQL On Solaris7 w/CGI via Apache 1.3.6
View as plain text  
Problem:  If I create a CGI in C that uses mySQL on Solaris7, it (the
          script) dies.  What happens is that the OS can't find some
          .so's that it needs - apparently libstdc++ and mysqlclient.

          It doesn't matter what LD_LIBRARY_PATH et. al. are set to;
          when the script is executed, they are no longer set to
          anything - Apache doesn't run login or profile scripts, and
          I can't find a way to alter LD_LIBRARY_PATH et. al. on a
          system-wide basis, only on a per-login one.

          In this case I'm using x86 Solaris7 but have had similar
          problems w/C++ CGI's doing the same thing on SPARC Solaris.
          I tried wrapping the CGI in a shell script that sets the
          LD_LIBRARY_PATH and execs the compiled script, but that
          doesn't work for some reason...  Actually, no setenv or
          set etc. commands seem to have any effect in this case.

          Apache can be modified to forcibly set these environment
          variables, but I would prefer not to do this as it could
          end up being a nuisance if and when I ever upgrade my Apache
          installation.  It seems as if there ought to be a graceful
          way to solve this problem; I just can't find it.

Workaround (for now):  I issued the following commands:

          cp /usr/local/lib/libstdc++* /usr/lib
          cp /usr/local/lib/mysql/mysqlclient* /usr/lib

   This seems to work, at least in preliminary testing.

   Unfortunately, symbolic links to the libraries don't work; the OS
   generates a max # links exceeded error.  I came up with this work-
   around from past run-ins with GNU C++ CGI scripts and from the PERL
   notes in the mySQL 3.23.10 docs.

This approach does, though, make me a little nervous... is there a
cleaner way to make these libraries findable?  One concern I have is
that since not all library files are copied into /usr/lib (there's
quite a few, some buried in subdirs for C++, in /usr/local/lib/...)
I'm risking finding a screwy bug somewhere down the pike, when the
system can't find something it needs.  Or, is this approach OK, or
a start (if so, what else do I need to do?)

My C/C++ compiler is GNU 2.8.1.

Again, Once the workaround is implemented, mySQL and C++ apps seem to
work fine from CGI's.  Also again, please let me know if this is a
solution or a potential source of problems, and if there's a better
way to get things working (perhaps I'm overlooking something simple?)

Please reply to this address as I'm not sure what list to subscribe
to in order to receive a reply.  It's important that I know if this is
going to work or not, so I'd appreciate an answer as soon as possible.
BTW the docs (3.23.10-alpha) specify "list.mysql.com", not "lists";
my first attempt to send this resulted in in a returned message.

Can't think of anything else to add.  Please let me know if I can
provide any additional information that would be of help.

Thanks,
Larry Morley
Thread
Using mySQL On Solaris7 w/CGI via Apache 1.3.6Larry Morley16 Feb