Why doesn’t Apache on Debian Wheezy create a core dump

apache-2.2segmentation-fault

I have seen several questions regarding this, and must have tried nearly everything, but still, Apache won't create a core dump on the production server.

This is the setup that actually works on my VM:

apt-get install gdb apache2-dbg php5-dbg libapr1-dbg libaprutil1-dbg

mkdir /tmp/apache-coredumps
chmod g+w,o+w /tmp/apache-coredumps/

cat <<EOF > /etc/apache2/conf.d/debugging
CoreDumpDirectory /tmp/apache-coredumps
EOF

ulimit -c unlimited
apache2ctl -t && service apache2 restart

On the VM, with "kill -11 " I can see "possible coredump in /tmp/apache-coredumps" in the logfile, but this part is missing on the production server.

This is what I also tried:

Server and VM both are Debian Wheezy running Apache 2.2.22 (mpm-prefork), PHP 5.4.45.

What else might be blocking the creation of a core dump?

Best Answer

Hope this helps someone.

Note that if you have PrivateTmp=true set in your /usr/lib/systemd/system/apache2.service (or whatever it's called on your system), meaning Apache actually looks for /tmp inside something like /tmp/systemd-private-c27fc5b152d546159d675e170641529b-apache2.service-IcEt0m/, Apache won't be able to write to that dir and you won't get cores dumped at all (due to the systemd tmp directory having 700 root-only perms).

The solution is to either set PrivateTmp=false or modify the permission of the systemd tmp directory after the server starts.

I wasted hours on this to only just now finally realize what the problem was.