[blfs-dev] PHP and httpd.conf

Pierre Labastie pierre.labastie at neuf.fr
Sun Dec 1 03:20:21 PST 2013

Le 29/11/2013 07:10, Thomas Trepl a écrit :
> Am Donnerstag, 28. November 2013, 22:51:15 schrieb Pierre Labastie:
>> Le 26/11/2013 18:27, Pierre Labastie a écrit :
> You are right, there is some other reason.  The pathes are relative to what is 
> defined in "ServerRoot" in httpd.conf.
> You may want to test 
> ServerRoot "/usr"
> LoadModule php5_module        lib/httpd/modules/libphp5.so
> An ServerRoot with ending slash (ServerRoot "/") is not allowed by the comment 
> in httpd.conf but it will works.
> ServerRoot "/"
> LoadModule php5_module        usr/lib/httpd/modules/libphp5.so
> An  approach could be to check which effects a specific ServerRoot will have and 
> than specifiy ServerRoot in the configuration and keep the pathes relative to 
> it. Apxs seems to do that anyhow.

Thanks Thomas, you showed me where to look at.
The issue is:

after apache install, the file httpd.conf contains many lines with
LoadModule <module_name>_module /usr/lib/httpd/modules/mod_<module_name>.so
(some of those are commented out)

while php adds:
LoadModule php5_module usr/lib/httpd/modules/libphp5.so

and there is a line:
#ServerRoot ""

The reason it is so:
during the install of apache, httpd.conf.in is populated with (only relevant
parts of Makefile here):
( \
for j in $(DSO_MODULES); do \
echo LoadModule $${j}_module $(rel_libexecdir)/mod_$${j}.so \
done \
) >> $(DESTDIR)$(sysconfdir)/httpd.conf

This means that during apache install, $(rel_libexecdir) is used. That
variable is defined in configure with:

ap_stripped=`echo $exp_libexecdir | sed -e "s#^${prefix}##"`
# check if the stripping was successful
if test "x$exp_libexecdir" != "x${ap_stripped}"; then
    # it was, so strip of any leading slashes
    rel_libexecdir="`echo ${ap_stripped} | sed -e 's#^/*##'`"
    # it wasn't so return the original

This means: if  $exp_libexecdir can be stripped off ${prefix}, then remove the
leading /. Otherwise, keep the name as is. Note that for BLFS, prefix is "",
so it cannot be stripped.

OTOH, in apxs, we have:
        my $dir = $CFG_LIBEXECDIR;
        $dir =~ s|^$CFG_PREFIX/?||

and then $dir is used to add the line in httpd.conf.

We see that apxs is unconditionally removing the / with $CFG_PREFIX. In BLFS,
$CFG_PREFIX is the same as $prefix, that is "". so apxs removes the leading /.

Now, I had a look at what Debian does. They have a big patch to apxs, because
they want to use a different layout for apache configuration. But there is
-        $dir =~ s|^$CFG_PREFIX/?||;
+        # Debian doesn't have a CFG_PREFIX, so this stuffs up:
+       # $dir =~ s|^$CFG_PREFIX/?||;

I propose to add:
sed '/dir.*CFG_PREFIX/s@^@^#@' -i support/apxs.in
before the configure step for apache package.

I guess that, if it is safe for Debian (where prefix is "" as for BLFS), it is
safe for us. I have rebuilt apache with that sed, and then php: the conf file
now contains:
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
and apache starts with no complaints (well, it says that it cannot determine
reliably the server name, but it is another story).

I do not know what more could be tested. If somebody uses BLFS for a http
server, let me know what I could try.


More information about the blfs-dev mailing list