Locating Apache Error Log on CentOS: Common Paths and Troubleshooting Guide


1 views

When working with Apache on CentOS, the default error log location is typically /var/log/httpd/error_log. However, depending on your installation method and configuration, this path might vary. Here's how to verify and locate your Apache error logs:


# Check Apache configuration for custom log paths
grep ErrorLog /etc/httpd/conf/httpd.conf
grep ErrorLog /etc/httpd/conf.d/*.conf

# Alternative method using apachectl
apachectl -S | grep "ErrorLog"

If the standard /var/log/httpd directory doesn't exist, check these alternative locations:

  • /var/log/apache2/error_log (common in some CentOS installations)
  • /var/log/apache/error_log
  • /usr/local/apache/logs/error_log (for source installations)

If you can't find the httpd directory in /var/log, consider these possibilities:


# Verify Apache installation status
rpm -q httpd || yum list installed httpd

# Check if logging is disabled in configuration
grep -i "loglevel" /etc/httpd/conf/httpd.conf

# Look for custom log locations in virtual hosts
grep -r "ErrorLog" /etc/httpd/

To set up a custom error log location, edit your Apache configuration:


# Example configuration in httpd.conf or virtual host
ErrorLog "/var/log/custom_apache_error.log"
LogLevel warn

# After configuration changes
systemctl restart httpd

Here's a real-world scenario where the error log wasn't in the default location:


# Step 1: Verify Apache is running
ps aux | grep httpd

# Step 2: Find the running process's open files
lsof -p $(pgrep httpd) | grep log

# Step 3: Check SELinux context if logs aren't being written
ls -Z /var/log/ | grep httpd

When troubleshooting Apache web server issues on CentOS, the error logs are your first line of defense. While the default location is typically /var/log/httpd/error_log, several factors can affect this path.

First, verify these standard locations:

# Check default httpd log directory
ls -la /var/log/httpd/

# Alternative common location
ls -la /var/log/apache2/

The actual log location is defined in Apache's configuration. Check these files:

# Main configuration file
grep ErrorLog /etc/httpd/conf/httpd.conf

# Virtual host configurations
grep -r ErrorLog /etc/httpd/conf.d/

If you can't find the httpd directory, consider these possibilities:

  • Custom compilation with non-standard paths
  • Different Apache packaging (e.g., from source vs RPM)
  • Log rotation moving files elsewhere

The most reliable method is querying Apache directly:

# For default installs:
apachectl -S 2>&1 | grep ErrorLog

# For custom builds:
httpd -V | grep HTTPD_ROOT
httpd -V | grep SERVER_CONFIG_FILE

If you need immediate access, you can temporarily redirect errors:

ErrorLog /tmp/apache_errors
LogLevel debug

# Then monitor with:
tail -f /tmp/apache_errors

Examine the running Apache processes to find log locations:

ps aux | grep httpd | grep -v grep
lsof -p $(pgrep httpd) | grep log