Find the location of apache configuration file

By | December 9, 2014

Apache is a web server that is available for all major platforms. Each OS stores the apache in a different directory or path, due to which it takes some effort to find the configuration file when needed. For example Ubuntu and fedora store it in different locations inspite of both being linux.

So here are some techniques to find the location of your apache configuration file quickly and easily. The fastest way is to check the following apache wiki page.

http://wiki.apache.org/httpd/DistrosDefaultLayout

It provides the directory structure of apache installation for all major platforms/OSes. Mostly likely your OS would be listed there.

Otherwise you can run a few commands on your system to find it manually. First of all find the location of your apache binary. It can be done in a number of ways as shown below

$ whereis apache2
apache2: /usr/sbin/apache2 /etc/apache2 /usr/lib/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gz

The output above shows the location of the apache binary to be /usr/sbin/apache2. Or use the ps command

$ ps -ef | grep apache
root      2972     1  0 10:01 ?        00:00:04 /usr/sbin/apache2 -k start
www-data  3027  2972  0 10:03 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  3888  2972  0 10:38 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  4302  2972  0 10:52 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  4323  2972  0 10:54 ?        00:00:00 /usr/sbin/apache2 -k start

On some linux distros its named as httpd. So replace apache2 with httpd. After having found the path to the apache binary, run the binary with the "V" option. It will list out useful information about the apache setup.

$  /usr/sbin/apache2 -V
Server version: Apache/2.2.22 (Ubuntu)
Server built:   Mar  8 2013 15:53:13
Server's Module Magic Number: 20051115:30
Server loaded:  APR 1.4.6, APR-Util 1.3.12
Compiled using: APR 1.4.6, APR-Util 1.3.12
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"

Check the values of HTTPD_ROOT and SERVER_CONFIG_FILE.
In the above output the httpd_root is /etc/apache2 and the server_config_file is apache2.conf

So the configuration file is /etc/apache2/apache2.conf

So find your configuration file and enjoy!!

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

2 Comments

Find the location of apache configuration file

Leave a Reply

Your email address will not be published. Required fields are marked *