So i was in the middle of a serious error debug session where some of the errors seemed to be apache’s fault. Probably some configuration adjustments, but for that i needed to see the current configuration (and change it if need be). But where is the httpd.conf file? After some practice, we easily look for it on the default places, depending on the linux distro (oh, i am assuming we are looking for it on a linux server), but let’s imagine we dont have a clue where it is. Now what? Read on.
Several ways to do it. But let’s take some time explaining the process:
ps -ef command lists all processes. You can pipe it to less to make it scrollable. Hell, you can pipe it to kingdom come, since its linux.
grep apache command looks for the word “apache” on the
ps -ef command results
You will get something like this (depending on your server and on how well you are into typing commands without messing up):
apache 20760 20753 0 Oct11 ? 00:00:56 /usr/sbin/httpd
Knowing that path, you can do this:
That -V switch will show the httpd compile settings, where you will see tons of info (out of this post’s scope).
The line you want is:
-D SERVER_CONFIG_FILE="[your httpd.conf path will be here]"
To make things easier, we can do another grep on the results to get the exact info we need:
Which will get you just the line you need:
Again, your results may vary.
Like the example above, your path can show as relative and not absolute. But relative to what? With the /usr/sbin/httpd -V command, you will also get info about HTTPD_ROOT:
So your config file location will be relative to exactly that.
or go straight for the kill:
Hope this helps someone. Yes, either of the 4 people that read this.