Where does Apache server store its configuration files?

Different Linux distributions and/or UNIX operating system, and control panels stores Apache web server configuration file at different locations. There are different ways to locate configuration file.

ADVERTISEMENTS

Apache is, by default, installed in /etc/httpd directory. But this path also depends on how apache has been compiled. Default configuration file name httpd.conf.

Using httpd command

To find the location where apache is installed and to print configuration file location, run the following command:
# httpd -v

Here is the output from my Fedora Core/RedHat (RHEL) Linux server:

Server version: Apache/2.0.54
Server built:   Jan 17 2006 06:36:00
Server's Module Magic Number: 20020903:9
Architecture:   32-bit
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 HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

HTTPD_ROOT points to default location /etc/httpd and line SERVER_CONFIG_FILE points to configuration file conf/httpd.conf. So the path is /etc/httpd/conf/httpd.conf

If you are using Debian Linux try apache-perl:

# apache-perl -V

cPanel/Plesk Control Panel

If you are using third party control panel, then you can find out Apache configuration file inside your /home/username/ directory or /var/www/vhosts/ directory.

Using find command

This is an old good (read as geekey) classic way to locate httpd.conf file:
# find / -name 'httpd.conf' -print

You may have to wait for few seconds/minute to search complete. Or try out locate command:
# locate httpd.conf

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
13 comments… add one
  • Ram bharoshe Sep 4, 2007 @ 9:48

    To find the location where apache is installed and to print configuration file location, run the following command:
    # httpd -V

    we have to use -V(capital) instead of -v(small).

    Thnx for your information

    Jai Shree Ram

    • Apoorv Gupta Oct 27, 2015 @ 11:14

      Using this , its saying command not found. Is there any other alternative ?

  • Ashu Kumar Raina Apr 20, 2009 @ 13:17

    Hi Sir, i am a operations engineer, but i m weak in Linuk field, could you please update/help me as your younger bro. Please sir i just need a little or basic cmnds regarding Linux. Could you please help me out.

    ashu raina

    • meanperson May 31, 2011 @ 7:48

      @Ashu Kumar Raina,

      Try reading..

    • koshurnafar Oct 17, 2012 @ 15:36

      kyoho gowe… hahahhaha..

  • rrrrew Oct 13, 2009 @ 10:18

    thank you

  • seema Aug 25, 2010 @ 10:38

    Hi,

    My Apache server is on Linux, it was configured and working fine. Recently the IP of the box got changed and since then I cannot navigate to the UI page. Can you please suggest where to change the IP.

    Thanks,
    seena

  • Jim Aug 10, 2012 @ 20:27

    On Ubuntu 12.04:
    apache2 -V

    -D HTTPD_ROOT=”/etc/apache2″
    -D SERVER_CONFIG_FILE=”apache2.conf”

  • Rico Oct 13, 2012 @ 13:47

    Ubuntu 12.04

    sudo apache2 -V

  • Gaurav Mishra Apr 2, 2013 @ 9:59

    Excelent Info

  • massimo Oct 11, 2013 @ 13:43

    HI,
    my problem is that httpd -V print che compiled settings, but you can start apache with any conf file you want with the option -f for instance :
    /bin/httpd -f /home/me/httpd.conf -k start
    is there a way to obtain the “running” configuration file?

    • Mark Oct 31, 2013 @ 18:53

      If you run:
      ps x | grep httpd

      the command collumn will show the full command line, which would include -f /path/to/httpd -k start

  • Mark Oct 31, 2013 @ 18:55

    you might want to run it as ps ax | grep httpd ( to make sure you get all processes )

Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.