Okay, I figured it out (thanks joschi for suggesting changing ServerRoot, that was part of the solution).
What I have is two Apache related locations, eg:
Y:\Servers\HTTP\Apache
- binaries
X:\Docs\Settings\Apache
- configuration files
So what I did was:
I moved the conf
and logs
directories from the binaries directory to the docs directory. In …Settings\Apache\conf
is httpd.conf which is nearly identical to httpd.conf.default. It has the following entry:
ServerRoot "Y:\Servers\HTTP\Apache"
#as normal
Then at the bottom of the file, I added
ServerRoot "X:\Docs\Settings\Apache"
- change the ServerRoot
Include "conf/Includes.conf"
- include customizations
The next step was simply to edit a couple of my Includ-ed .conf files that use LoadModule, and passing the full path to the .so file.
If I had lots of LoadModule calls in my customized .conf files, instead of using absolute paths, what I would do is to create two new .conf files, (eg BinLoc.conf and ConfLoc.conf) each containing a single ServerRoot directive to set it to the binary/docs directories. Then I could wrap the LoadModule calls as such:
Include "conf/BinLoc.conf"
LoadModule ssl_module modules/mod_ssl.so
Include "conf/ConfLoc.conf"
(Unfortunately the second Include would have to use an absolute path to the settings directory, so it would kind of defeat the purpose.)
Finally, I set Apache to load the httpd.conf file from my docs directory (ie load X:\Docs\Settings\Apache\httpd.conf
). There were several ways to do this. The installer uses the ConfigArgs registry entry for the Apache service, but I decided not to use that and emptied it out. I tried setting HKLM\SOFTWARE\Apache Software Foundation\Apache\2.2.15\ServerRoot to X:\Docs\Settings\Apache
, but Apache doesn’t seem to pick that up. I decided to go with the command-line. I modified my Install.bat so that when it creates the Apache service, it passes the httpd.conf file using the -f
argument (editing a batch file is much easier/faster than modifying a multi-string in the registry).
In fact, I was already passing the .conf file using the -f
before, so ultimately the only changes that were required (other than moving the folders to my docs directory) were to add an extra ServerRoot directive to httpd.conf to reset the configuration directory and to change the few LoadModule directives in my non-default (ie customized) .conf files to use absolute paths (though if there were lots of them, I could set it back to the binary .
Apache now runs just fine, and the (replaceable) binaries and the (irreplaceable) configuration files are nice and separate. :)
(Oh, and the logs are elsewhere, eg X:\Docs\Logs\Apache
. The log-related entries in httpd.conf use an absolute path to that, but should I ever change the log directory, it’s a simple matter of search-and-replace-in-files to update, just like it would be with the absolute paths for the LoadModule directives in my custom .conf files if I changed the location of the binaries.)