Skip to content

Instantly share code, notes, and snippets.

@mkubenka
Created March 23, 2020 16:03
Show Gist options
  • Save mkubenka/cf977e9178a394850bd7b4d67efee3d0 to your computer and use it in GitHub Desktop.
Save mkubenka/cf977e9178a394850bd7b4d67efee3d0 to your computer and use it in GitHub Desktop.

Revisions

  1. mkubenka created this gist Mar 23, 2020.
    58 changes: 58 additions & 0 deletions centos_php_fpm_coredumps.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    # CentOS PHP-FPM coredumps

    > https://wiki.archlinux.org/index.php/Core_dump
    Enabling core dumps for PHP-FPM on CentOS 7 require several steps.

    Set the `rlimit_core` directive in */etc/php-fpm.d/pool.conf* and */etc/php-fpm.conf* to unlimited:

    ```ini
    rlimit_core = unlimited
    ```

    Set system parameters to generate core dumps:

    ```bash
    # Send dumps via a pipe to the systemd-coredump
    sysctl kernel.core_pattern='| /usr/lib/systemd/systemd-coredump %p %u %g %s %t %c %e'

    # Enable core dumps for processes using setuid().
    sysctl fs.suid_dumpable=2

    # Do not add PID to core dump file.
    sysctl kernel.core_uses_pid=0
    ```

    Add to */etc/systemd/system.conf* file:

    ```bash
    DefaultLimitCORE=infinity
    ```

    Reload systemd configuration:

    ```bash
    systemctl daemon-reload
    ```

    Restart PHP-FPM:

    ```bash
    systemctl restart php-fpm
    ```

    To confirm core dump was generated look for `SIGSEGV - core dumped` in PHP-FPM error log:

    ```
    [11-May-2015 15:34:03] WARNING: [pool www] child 2553 exited on signal 11 (SIGSEGV - core dumped) after 6943.521858 seconds from start
    ```

    To interact with core dump we can use `coredumpctl` utility:

    ```bash
    coredumpctl list

    coredumpctl info 123

    coredumpctl gdb 123
    ```