0

Httpd processes use a non-default configuration file if they are run with the -f flag.

For example

/home/myuser/apache/httpd-2.4.8/bin/httpd -f /confFiles/apache/2.4.8/apache.conf -k start

will use this configuration file: /confFiles/apache/2.4.8/apache.conf

I need to get this location and would rather not have to check for possible -f flags used to start httpd.

The answer here says to run /path/to/httpd -V and concatenate

-D SERVER_CONFIG_FILE="conf/httpd.conf"

with

-D HTTPD_ROOT="/etc/httpd"

to get the final path to the config file.

However, this path will not be the correct one if the -f flag is used to start the httpd process.

Is there a command that can get the config file that is actually being used by the process?

Community
  • 1
  • 1
Roko
  • 35
  • 1
  • 7

1 Answers1

0

The answer you refer to mentions the paths httpd was compiled with, but as you say those can be manually changed with parameters.

The simple way to check is the command line, if process is called "httpd" (standard name), a simple ps will reveal the config file being used:

ps auxw | grep httpd

Or querying the server if server has mod_info loaded, in command line or with your favourite browser:

curl "http://yourserver.example.com/server-info?server" | grep -i "config file"

Note: mod_info should not be publicaly available for everyone to see.

Daniel Ferradal
  • 2,727
  • 1
  • 13
  • 19
  • Thanks, I'm writing some automation code, and wondering if there's a surefire way to get the correct conf file instead of having to check for the f flag and (if it's not present) then also look at the compiled paths. – Roko Jan 12 '17 at 09:18
  • if the -f flag is not present then the default value should apply which you can get with httpd -V or still mod_info. – Daniel Ferradal Jan 12 '17 at 09:20