4

I would like to enable core dumps in my Apache web server.
Since I have PHP 5.5 and OPcache my Mediawiki site crashes with the following error:

child pid ... exit signal Segmentation fault (11)

So I would like to get more information through the core dump.

I created a directory: /tmp/apache-coredump owned by http:http (my apache user and group) and with the 777 rights.
I added to the httpd.conf file:

CoreDumpDirectory   "/tmp/apache-coredump"

But, now (with the CoreDumpDirectory instruction) my Apache server crashes on start-up:

sudo systemctl restart httpd

Job for httpd.service failed. 
See 'systemctl status httpd.service' and 'journalctl -xn' for details.

The journal give me the following info

apachectl[4149]: CoreDumpDirectory /tmp/apache-coredump does not exist

I checked, the directory exist 0_°

Edit:
I changed the CoreDumpDirectory instruction in the httpd.conf file and it allows me to start my web server

CoreDumpDirectory /tmp

Without the CoreDumpDirectory instruction, there is no core dump generated in the ServerRoot (/etc/httpd) directory.
I'm on Archlinux 3.10.6-2 64-bits with Apache/2.2.25 Prefork

Nicolas
  • 387
  • 2
  • 5
  • 12
  • 1
    I can't be sure based on your description. But is it possible that you run apache in a root jail? that would be a reason why it can't find that directory. – replay Aug 19 '13 at 15:44
  • I don't think my web site is in a root jail (but I'm sure of nothing today). How to be sure I'm not and what to do if I am? I tested `/tmp/apache-coredump` as a file and it failed, but I tested `CoreDumpDirectory /tmp` and it allowed me to start Apache but without core dump. – Nicolas Aug 19 '13 at 15:57
  • You can be sure if you start your apache without the coredump parameter, so it starts successfully. then you check for the pid of one of the apache processes, then you execute `ls -lha /proc//root`. the root entry of the folders in /proc is always pointing to the root for that process, so if the process is running in a jail root, this should point to somewhere else than `/`. – replay Aug 19 '13 at 16:06
  • Thanks for the tip. The `ls -lha /proc//root` command returns `/`. So my web server doesn't run in a root jail :) `CoreDumpDirectory /home//folder` also works but doesn't allow me to generate the core dump file. – Nicolas Aug 19 '13 at 16:11
  • @Dennis Kaarsemaker, SELinux is not installed on my Archlinux system – Nicolas Aug 19 '13 at 19:38
  • 1
    I had the same issue, and after trying various things I also ended up setting `CoreDumpDirectory ` to just `/tmp`. But in any case, I guess the subdirectory would be deleted on a reboot, causing apache not to start. Perhaps it rejects subdirectories of `/tmp` for that reason... but it seems a bit far-fetched. – danmichaelo Apr 18 '16 at 14:01

2 Answers2

3

Core dumps are generally disabled by default since they tend to waste disk space, you need to switch them on for your apache session.

$ ulimit -a
core file size          (blocks, -c) 0
[...]
$ ulimit -c unlimited
$ systemctl restart httpd

Also, do you have SELinux enabled? Output of ls -alZ /tmp/apache-coredump

vbraun
  • 277
  • 1
  • 2
  • `ls -alZ /tmp/apache-coredump` -> `drwxrwxrwx 2 http http ? 40 19 août 21:40 .` `drwxrwxrwt 18 root root ? 520 19 août 21:40 ..` But as `/tmp/apache-coredump` failed with the CoreDumpDirectory instruction I use `/home//apache-coredump` -> `drwxrwxrwx 2 http http 4096 19 août 18:01 .` – Nicolas Aug 19 '13 at 19:47
  • Thanks for the ulimit tip, I passed from 0 to unlimited but it still doesn't work. – Nicolas Aug 19 '13 at 19:49
0

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.

Artem Russakovskii
  • 1,003
  • 3
  • 12
  • 25