here's a tricky problem that I've struggled with for several weeks now:
I want to install an Apache server as part of my deployment process. Using Advanced Installer, I have prepared a user-friendly installer which automatically installs the entire program and all related services. This works fine so long as I install the program in a consistent location.
However, it starts getting more complicated. One of the requirements is that the entire program should be able to be installed in any location, even a totally unexpected folder, and still work, including the Apache server service. That is where things are getting tricky.
In essence, that means I have to set my ServerRoot relative to the installation path, or more specifically, the subdirectory of the Apache2.4/bin directory from which I try to install start the NFTB service using:
- Code: Select all
NFTB -k install -n NFTB
NFTB -k start -n NFTB
Installation usually works fine. However, when trying to start this with any of the following configuration variants:
- Code: Select all
ServerRoot "../Apache2.4"
ServerRoot "/../Apache2.4"
ServerRoot "/../.."
ServerRoot "../../"
...the service fails to start with the following error message:
Syntax error on line 38 of D:/Unexpected Folder/Totally Unexpected Folder/NBL/Apache2.4/conf/httpd.conf: ServerRoot must be a valid directory
There is one variant that produces a slightly different error message. If I configure the ServerRoot as:
- Code: Select all
ServerRoot ".."
...the service starts but instantly crashes, with the following error logged in the Event Viewer:
Syntax error on line 76 of D:/Unexpected Folder/Totally Unexpected Folder/NBL/Apache2.4/conf/httpd.conf: Cannot load modules/mod_access_compat.so into server: The specified module could not be found.
I've been on this issue on and off for about two weeks now, and have already searched the web quite extensively. However, all examples and solutions I have found so far include setting absolute server paths which is not something I can do with this project. Is there truly no way to configure Apache to use a relative path as the server log? As is, I can't even see which path Apache tries to access for my various configuration attempts since the logging does not work if that first step already fails, and it also does not work if it can't locate the modules. It would be really helpful to have an error message along the lines of:
Syntax error on line 38 of D:/Unexpected Folder/Totally Unexpected Folder/NBL/Apache2.4/conf/httpd.conf: ServerRoot must be a valid directory. Currently specified directory C:/../Apache2.4 does not exist
Current Workaround
I don't know if this is just a workaround or the actual solution to the problem, but after trying out quite a few variants for ServerRoot, I have found out one variant that appears to correctly set the ServerRoot as the subdirectory of the directory from which the service is started.
This variant is to not set the server root at all in the httpd.conf. This apparently causes Apache to automatically default to using the subdirectory of the directory from which the service is started as the ServerRoot. I have no documentation to back this behaviour up, but now my service finds all modules in the ../modules folder and faithfully writes its logs in the ../logs folder no matter where I install it, so apparently that works.
However, for some reason I remain unconvinced that this is truly the ideal solution. Is there a better way to this?
Thanks in advance