How to Identify and Verify the Active Apache Configuration File on macOS


2 views

When I first noticed Apache on my Mac wasn't respecting changes to /etc/apache2/httpd.conf, I went digging deeper. The smoking gun was when I completely deleted the file and Apache kept running normally - clearly it was loading configurations from elsewhere.

Method 1: Using httpd command

httpd -V | grep SERVER_CONFIG_FILE

This reveals the compiled-in default configuration path. On modern macOS, you'll typically see:

SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

Method 2: Checking includes

Modern Apache installations heavily use the Include directive. Look for these lines in your main config:

Include /private/etc/apache2/extra/httpd-vhosts.conf
Include /private/etc/apache2/extra/*.conf
Include /private/etc/apache2/users/*.conf

To see every file being processed during startup:

apachectl -t -D DUMP_CONFIG 2>&1 | grep -E '^(# |Processing )'

Example output showing the load sequence:

Processing config file: /private/etc/apache2/httpd.conf
Processing config file: /private/etc/apache2/extra/httpd-userdir.conf
Processing config file: /private/etc/apache2/extra/httpd-vhosts.conf

On macOS, pay special attention to:

  • /private/etc/apache2/ - Main config directory
  • /usr/local/etc/apache2/ - Homebrew installations
  • /Library/Server/Web/Config/apache2/ - Server.app installations

When virtual hosts aren't working, check:

# First verify NameVirtualHost is set
NameVirtualHost *:80

# Then ensure proper VirtualHost blocks

    ServerName mysite.local
    DocumentRoot "/Users/me/Sites/mysite"
    
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    

To check if certain directives are being overridden:

apachectl -t -D DUMP_RUN_CFG 2>&1 | grep DocumentRoot

This will show you the actual DocumentRoot being used after all configurations are processed.

If PHP works despite the module line being commented, it's likely loaded via:

LoadModule php5_module /usr/local/opt/php/libexec/apache2/libphp5.so

Check /etc/apache2/other/php5.conf which macOS often uses for PHP configuration.


When working with Apache on macOS, many developers encounter situations where modifications to httpd.conf don't seem to take effect. As you've discovered, this usually means Apache is loading configuration from a different location than expected.

The most reliable way to identify the active configuration file is by querying Apache directly:

apachectl -V | grep SERVER_CONFIG_FILE

On modern macOS systems, this typically returns:

SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

Apache often includes additional configuration files. To see all loaded configurations:

apachectl -t -D DUMP_CONFIG | less

Or for just the include directives:

grep -i "Include" /private/etc/apache2/httpd.conf

For Virtual Hosts specifically, check these common locations:

# Main configuration
/etc/apache2/httpd.conf

# Additional includes
/etc/apache2/extra/httpd-vhosts.conf
/etc/apache2/extra/httpd-userdir.conf

When DocumentRoot doesn't match expectations, trace its definition:

# Search through all config files
grep -r "DocumentRoot" /etc/apache2/

# Verify the active DocumentRoot
curl -I localhost | grep -i "DocumentRoot"

The PHP module might be loaded via different mechanisms:

# Check loaded modules
apachectl -M | grep php

# Look for additional config files
find /etc/apache2 -name "*php*" -type f

Modern macOS systems often use LoadModule php7_module instead of php5_module.

  • Use apachectl configtest to verify syntax
  • Check error logs: tail -f /var/log/apache2/error_log
  • Temporarily add unique comments to identify which config is loaded