I ran into numerous solutions to enable Apache HTTPD2 core dumps under Debian 9. With some trial and error, this is how I got apache2 to make core dumps as a result of a segfault occuring.
Note: In some situations, enabling core dumps on a production server can present a security risk.
We need to install
systemd-coredump to configure and view the dumps. Additionally, on the system where the dumps are analysed, we will need both the GNU Project Debugger (GDB) and the apache2 debugging symbols.
sudo apt install -y systemd-coredump gdb apache2-dbg
apache2-dbg package is not available on Debian 10. You might need to recompile apache2 and then install the resultant apache2-dbg
.deb file with dpkg.
CoreDumpDirectory directive into the apache2 (httpd) configuration:
echo "CoreDumpDirectory /tmp" | \ sudo tee /etc/apache2/conf-available/core-dumps.conf
Note that the
CoreDumpDirectory value appears to be ignored in so far as where apache2 will store the core dumps. The specified directory however, must exist otherwise apache2 will not start.
Enable the new configuration:
sudo a2enconf core-dumps
sudo systemctl restart apache2
Now upon segfault, apache2 will log:
[Tue Jul 27 18:00:58 2021] [notice] [pid 2572] mpm_unix.c(430): [client AH00051: child pid 2574 exit signal Segmentation fault (11), possible core dump in /tmp
Accessing Apache HTTPD2 Core Dumps
Core dumps will be saved to
coredumpctl list to list the dumps and, for example,
coredumpctl gdb /usr/sbin/apache2 to launch GDB with the most recent apache2 dump.
- No need to apply ulimit tweaks (core dump size limits)
- No need to change
/usr/sbin/apache2ctlor any init scripts
- No need to edit
- Tested with Debian apache2 2.4.25-3+deb9u10