How to get an apache core dump?

ulimit -c unlimited only effects your current shell.

You can confirm this by looking at output cat /proc/$(pidof -s apache2).

I added ulimit -c unlimited to /etc/default/apache2 and now cat /proc/$(pidof -s apache2)/limits includes

Max core file size        unlimited            unlimited            bytes