Subject: RE: Startup Script

From: "Boyle Owen" <[email-masked]>
Date: Thu, 31 Oct 2002 09:04:27 +0100

To expand a little on my previous post:

When you run a shell-script, it forks a new shell which doesn't usually
inherit environment variables from the calling shell. So you have to set
any envs in the script. To do this under the standard shell (i.e.
/bin/sh) you need two lines:

	LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib:/usr/openwin/lib"
	export LD_LIBRARY_PATH

Under the tcsh, you'd only need one:

	setenv LD_LIBRARY_PATH
/lib:/usr/lib:/usr/local/lib:/usr/openwin/lib

So that's how to get LD_LIBRARY_PATH to work.

However, the use of LD_LIBRARY_PATH is generally discouraged for several
reasons - it breaks encapsulation by making the execution of a binary
dependent on the shell (hence your problem), it invites namespace
problems if two libraries in different lib directories have the same
name (the binary will load the first it finds on the path), on large
projects with lots of development libs, the path can become unfeasibly
large, etc. etc.

A much cleaner solution is to define the paths when compiling. Thus the
binary carries with it the paths to just those directories it needs. To
do this, define the "CFLAGS" environment variable in the shell in which
you configure apache, i.e.

	CFLAGS="-L/lib -R/lib -L/usr/lib -R/usr/lib -L/usr/openwin/lib
-R/usr/openwin/lib"
	export CFLAGS
	./configure <additional options>

When you run make, you will find that the CFLAGS above will appear on
the compile line and the resulting binary will find its libraries from
these internal symbols.

Compiling is a bit of a black art at times and I don't really understand
all of it myself - the advices in this note are just some distillations
of my own experiences and things I found when trawling the web..

Rgds,

Owen Boyle

-----Original Message-----
From: Lawrence Cole [mailto:[email-masked]]
Sent: Mittwoch, 30. Oktober 2002 21:05
To: [email-masked]
Subject: RE: Startup Script

Boyle,

Thank you for your suggestions.

Adding "LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/openwin/lib"
to the startup script does not help.

Sourcing root's .profile before running the "apachectl startssl" command
does not help.  The LD_LIBRARY_PATH is set in the .profile.

So the last thing to try are the -R and -L compile-time option pairs for
each library.  I have a rookie question to ask.  Where do I use these?
I can't use them with the .configure or make commands.  Do I need to
edit the Makefile?  Can you give me an example?

Regards,

Lawrence

-----Original Message-----
From: [email-masked]
[mailto:[email-masked]] On Behalf Of Boyle Owen
Sent: Wednesday, October 30, 2002 2:21 AM
To: [email-masked]
Subject: RE: Startup Script

Quick fix is to put in the startup script:

LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/openwin/lib

before it tries to start apache..

Better fix is to recompile apache with the additional compile-time
options: "-L/usr/openwin/lib -R/usr/openwin/lib" etc. (one pair for each
lib). This should build the paths to the libs into the binary and then
you don't need LD_LIBRARY_PATH at all.

-----Original Message-----
From: Lawrence Cole [mailto:[email-masked]]
Sent: Mittwoch, 30. Oktober 2002 04:52
To: [email-masked]
Subject: Startup Script

Greetings everyone,

I realize this situation has come up before, but none of the suggestions
I have seen have worked for me.

I have created an Apache 1.3.26 / mod_ssl 2.8.10 server.  No problems
creating it, and no problems starting from the command line.  I am
however, unable to start automatically at boot using a script in the
rc3.d directory.  When I try to start it automatically using:

#!/bin/sh
#
# Start SSL-Aware Apache http daemon
#
echo "Start SSL-Aware Apache httpd"
/opt/apache/bin/apachectl startssl

I get the following error:

ld.so.1: /opt/apache/bin/httpd: fatal: libexpat.so.0: open failed: No
such file or directory Killed /opt/apache/bin/apachectl startssl: httpd
could not be started

Once the system is booted up the LD_LIBRARY_PATH is
"/lib:/usr/lib:/usr/local/lib:/usr/openwin/lib", and I can run
"/opt/apache/bin/apachectl startssl" just fine.  For automation reasons,
I need to boot at startup.  Any suggestions?

Regards,

Lawrence

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please notify the sender urgently
and then immediately delete the message and any copies of it from your
system. Please also immediately destroy any hardcopies of the message.
You must not, directly or indirectly, use, disclose, distribute, print,
or copy any part of this message if you are not the intended recipient.
The sender's company reserves the right to monitor all e-mail
communications through their networks. Any views expressed in this
message are those of the individual sender, except where the message
states otherwise and the sender is authorised to state them to be the
views of the sender's company. 
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [email-masked]
Automated List Manager                            [email-masked]

______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [email-masked]
Automated List Manager                            [email-masked]

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please notify the sender urgently
and then immediately delete the message and any copies of it from your
system. Please also immediately destroy any hardcopies of the message.
You must not, directly or indirectly, use, disclose, distribute, print,
or copy any part of this message if you are not the intended recipient.
The sender's company reserves the right to monitor all e-mail
communications through their networks. Any views expressed in this
message are those of the individual sender, except where the message
states otherwise and the sender is authorised to state them to be the
views of the sender's company. 
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [email-masked]
Automated List Manager                            [email-masked]

---

From: "Lawrence Cole" <[email-masked]>
Date: Sun, 3 Nov 2002 23:13:56 -0700

Owen,

Both solutions work.  Thank you very much for your time and patience.

Regards,

-Lawrence

-----Original Message-----
Sent: Thursday, October 31, 2002 1:04 AM

	setenv LD_LIBRARY_PATH

Rgds,

Owen Boyle

-----Original Message-----
From: Lawrence Cole [mailto:[email-masked]]
Sent: Mittwoch, 30. Oktober 2002 21:05
To: [email-masked]
Subject: RE: Startup Script

Boyle,

So the last thing to try are the -R and -L compile-time option pairs for
each library.  I have a rookie question to ask.  Where do I use these? I
can't use them with the .configure or make commands.  Do I need to edit
the Makefile?  Can you give me an example?

Regards,

Lawrence

-----Original Message-----
From: Lawrence Cole [mailto:[email-masked]]
Sent: Mittwoch, 30. Oktober 2002 04:52
To: [email-masked]
Subject: Startup Script

Greetings everyone,

#!/bin/sh
#

Regards,

Lawrence