title: Apache ~ Configuring Server Root for Relative Paths
body: <p>I am having trouble with an Apache Server service not finding the module files when I try to use relative paths.</p>
  
  <p>The essence of the issue is that my project has an Apache service subfolder, and that the Apache service needs to be able to run from regardless of where the user decides to install the program.</p>
  
  <p>The file where the Apache files can be found in the project are as follows:</p>
  
  <ul>
  <li>Apache Root: [APPDIR]/Apache2.4</li>
  <li>Service File (xxx.exe): [APPDIR]/Apache2.4/bin</li>
  </ul>
  
  <p>Now, how can I configure the ServerRoot in the httpd.conf to recognize the correct root?</p>
  
  <p>My current setup is:</p>
  
  <pre><code> ServerRoot ".."
  </code></pre>
  
  <p>This works fine when running the xxx.exe directly. However, it fails when trying to install it as a service. I assume this is because the service does not run the xxx.exe directly, but rather executes it from another directory, so naturally ServerRoot ".." does not work anymore. The error message this produces in the Application Log is:</p>
  
  <pre><code> &gt;&gt;&gt; xxx.exe: Syntax error on line 81 of C:/Release Static/Apache2.4/conf/httpd.conf: Cannot load modules/mod_access_compat.so into server: The specified module could not be found.     .
  </code></pre>
  
  <p>My first approach to fix this was trying to log the exact path where Apache is trying to look for the file. For this purpose, I tried having Apache log something in the error log by writing a LogMessage directive in the httpd.conf before the line that caused  the error. However, I was unable to even log something as simple as a test message. The code I  tried using was:</p>
  
  <pre><code> LoadModule log_config_module "C:/Release Static/Apache2.4/modules/mod_log_config.so"
   LoadModule log_debug_module "C:/Release Static/Apache2.4/modules/mod_log_debug.so"
   ErrorLog "C:/Release Static/Apache2.4/logs/error.log"
   LogLevel debug rewrite:trace8
   LogMessage "Test"
  </code></pre>
  
  <p>This apparently worked since the error continued to occur only later when trying to load modules with relative paths. However, it did not log "Test" in the error.log either, so there apparently is something else that I'm missing.</p>
  
  <p>If I got this much to work, my next step would be trying to figure out a way for Apache to return me the absolute path of the ServerRoot directory it tries to use, and then modify the value accordingly until I have a solution where the  relative path always points to the  installation directory.</p>