rfc:apxs-loadmodule

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.

Note

This optional configure switch will essentially just be taking advantage of a feature that is already built-in to APXS. If this new switch is not specified, the default behavior will be identical to what it is now.

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

After prolonged and at-times agonizing consideration, I have decided not to include support for the older APXS that comes with Apache 1.3.x. As such, this new switch will only be applicable to APXS2 (Apache 2.x). This decision was made for the following reasons:

  • Apache 1.3.x was officially “EOL'd” back in 2010. It is no longer supported by the ASF.
  • According to an informal poll conducted by cPanel about a year ago, 91% of their users report that they use Apache 2.x instead of 1.3.x in all circumstances. That number is likely to be even higher today.
  • Of all the requests for this feature I have seen that were posted in recent years, I have not been able to find a single one who was using Apache 1.3.x instead of 2.x.
  • Keeping 1.3.x support for legacy compatibility does not necessitate continuing to apply new features to it. On the contrary, continuing to expend resources (even a small amount as would be the case this time) supporting something that its makers already EOL'd a long time ago would set a bad precedent.
  • When repeatedly asked on the listserv, nobody in the PHP community expressed support for applying this to Apache 1.3.x as well.
  • Given current sentiment, it is reasonable to predict that the PHP community will opt to officially deprecate Apache 1.3.x in the relatively near future.

For the above reasons, this new optional switch will not be made available for Apache 1.3.x. Instead, its configure options will remain unchanged.

Final Thoughts

This should make PHP just a little bit easier to manage without any adverse consequences. It simply makes available to PHP users a feature that is already built-in to APXS.

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.

Vote

Changelog

Version 1.40 : Status => Accepted.

Version 1.30 : Voting.

Version 1.21 : Typo correction.

Version 1.20 : Content revisions based on PHP Internals discussions. Posted decision on APXS vs. APXS2 question.

Version 1.10 : Status => Under Discussion.

Version 1.01 : Typo corrections.

Version 1.00 : Initial proposal.

rfc/apxs-loadmodule.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1