rfc:apxs-loadmodule

This is an old revision of the document!


Request for Comments: APXS LoadModule Option in configure

Abstract

This RFC proposes the addition of an option to PHP's configure script that allows the user to specify whether they want Apache's main configuration file (heretoafter referred to as, “httpd.conf”) appended automatically with the LoadModule statement.

Background

PHP Configuration Script

When the configure script is executed, a vast number of options are available to the user, from enabling/disabling different PHP extensions to specifying the path to APXS. This bash script is key to preparing PHP for compilation. Among other things, this script is responsible for generating the Makefile.

APXS

APXS is an acronym that stands for, “APache eXtenSion tool.” As the name indicates, this is a command-line tool, typically bundled with Apache, that is responsible for building and installing extension modules for the Apache HTTP server.

Like PHP's configure script, APXS has a number of helpful options available to the user. One of these options, “-a”, tells APXS to add an appropriate LoadModule entry to httpd.conf. Another option, “-A”, tells APXS to add this entry but make it commented (i.e. “#LoadModule”). If neither option is specified, APXS will not add the entry to httpd.conf at all.

More information on APXS can be found at: http://httpd.apache.org/docs/2.0/programs/apxs.html

Makefile

APXS is called from the Makefile when you run, “make install”. This only applies if you're using mod_php on Apache, of course. This does not apply to native (i.e. non-Cygwin) Windows builds.

Current Behavior

Despite APXS's native support for specifying whether or not httpd.conf should be overwritten, the PHP configure script currently does not give you any option to take advantage of this. Instead, the “-a” tag is included as static text and cannot be changed without manually altering the configure script and removing it.

The Problem

Many developers and IT personnel perfer to isolate PHP in its own separate configuration file (i.e. php.conf), which includes the LoadModule directive. However, whenever PHP is recompiled and reinstalled for one reason or another, “make install” automatically writes a “LoadModule” line to httpd.conf. As a result, a warning notice is thrown whenever Apache is restarted, essentially stating that the “duplicate” LoadModule directive in the included php.conf was disregarded, rendering it meaningless. To resolve this, the user must manually edit httpd.conf and comment or remove the LoadModule line that was added. If you're doing QA testing and rebuilding PHP numerous times, this can get SUPER annoying rather quickly.

A bug was actually filed for this problem back in 2004. Specifically, Request #28181 for PHP 4.3.6. This bug was never closed. I stumbled across it a couple months ago and assigned it to myself. The full bug report can be found here: https://bugs.php.net/bug.php?id=28181

The Solution

Quite simple, really. Add an option to the configure script that allows the user to optionally take advantage of this option provided natively by APXS. Here's what I ultimately settled on:

--with-apxs2-hook[=TYPE] : Where TYPE is one of: “yes”, “no”, or “commented” [TYPE=yes].

The “yes” option is default if just “--with-apxs2-hook” is specified without a TYPE or if it's not specified at all. This will ensure backwards compatibility with pre-made scripts and tutorials that reference the configure script.

It's Already Written

I've already made the changes and tested them successfully on Ubuntu. However, I was doing this against a 5.3.4 install so I'll need to re-apply it to 5.3.10 and 5.4(?) then re-test if/when this is approved before I'll post the actual commit. But I can say at least that I do have a working proof of concept.

APXS vs. APXS2

Currently, I only have this applied to APXS2 (i.e. Apache 2.x). I have not applied it to APXS (i.e. Apache 1.x). I can apply it to 1.x as well, though I'd then have to install a working copy of Apache 1.3.x for testing, which would be a minor annoyance.

What do you think? I can apply it to both, but are we even still supporting Apache 1.3.x at this point?? I don't want to waste my time doing that if 1.x is considered deprecated. Please share your thoughts on this in the discussion! If enough of you think I should, I'll bite my tongue and do it.

Final Thoughts

This should make PHP just a little bit easier to manage without any adverse consequences (at least, none that I can think of).

It occurred to me that the next logical step would be to expand this so that the user could opt to create a separate configuration file (i.e. php.conf) and have an include directive added to httpd.conf if it's not already there. Unfortunately, it looks like APXS does not currently support this. It just assumes httpd.conf. So any discussion about that approach would, presumably, first have to take place within the Apache project. In the meantime, we can at least take advantage of what's already there.

Changelog

Version 1.10 : Status => Under Discussion.

Version 1.01 : Typo corrections.

Version 1.00 : Initial proposal.

rfc/apxs-loadmodule.1329786516.txt.gz · Last modified: 2017/09/22 13:28 (external edit)