How to enable Apache2 core dumps for debuging on Debian 7

Step-by-step guide

Proceed with the following steps:

  1. Install dependencies
    aptitude install apache2-dbg libapr1-dbg libaprutil1-dbg
  2. Add in the beginning of script ‘/etc/init.d/apache2’, the following:
    # set ulimit for debugging
    ulimit -c unlimited
  3. Add in to “/etc/apache2/httpd.conf”:
    cat /etc/apache2/httpd.conf
    # 20150129 add coredump to investigate the "Segmentation fault" event
    #
    CoreDumpDirectory /tmp/apache2_coredump
    
    ^D
  4. Create the folder and set proper permissions:
    mkdir /tmp/apache2_coredump
    chown www-data:www-data /tmp/apache2_coredump
    chmod 777 /tmp/apache2_coredump
  5. Test apache2 configuration for errors:
    apache2ctl -t
  6. If there are no errors, restart the apache2 server:
    /etc/init.d/apache2 stop;
    /etc/init.d/apache2 start;
  7.  When you see this in error_log:
    [Thu Feb 05 10:44:06 2015] [notice] child pid 5886 exit signal Segmentation fault (11), 
    possible coredump in /tmp/apache2_coredump

    you will be able to extract useful information from coredump:

    gdb apache2 /tmp/apache2_coredump/core
The guide was borrowed from: jrs-s.net