Install Packages
Run following command:
apt-get install gdb php5-dbg
Linux Changes
First you need to enable core dumps in linux
su - echo '/tmp/core-%e.%p' > /proc/sys/kernel/core_pattern echo 0 > /proc/sys/kernel/core_uses_pid ulimit -c unlimited
PHP5-FPM Config Changes
Then you need to make changes to php5-fpm config:
vim /etc/php-fpm.d/www.conf
and uncomment following line
rlimit_core = unlimited
Restart FPM
service pgp5-fpm restart
Check core dumps
If you see in fpm error logs:
[05-Jun-2014 06:21:12] WARNING: [pool www] child 631273 exited on signal 11 (SIGSEGV - core dumped) after 20.263546 seconds from start
Go to /tmp
folder and you will see files like:
# ls -l /tmp/core* -rw------- 1 www-data www-data 133021696 Jun 5 06:05 /tmp/core-php5-fpm.630436 -rw------- 1 www-data www-data 66887680 Jun 5 06:09 /tmp/core-php5-fpm.630735 -rw------- 1 www-data www-data 66887680 Jun 5 06:11 /tmp/core-php5-fpm.630832 -rw------- 1 www-data www-data 72388608 Jun 5 06:21 /tmp/core-php5-fpm.631273
Reading a backtrace
Use following syntax to run gdb
gdb /usr/sbin/php5-fpm /tmp/core-php5-fpm.630832
Above will show useful info about crash from dump file and open a gdb shell.
You can run bt
command in it to get more detailed output.
(gdb) bt