HOWTO: Stop nginx + php-fpm from truncating your stack trace/error message

This one took me quite a while to figure out so hopefully someone will have use of this post.

As you are here, you have probably already figured out that your stack traces/error messages are being truncated at 1024 characters/bytes and that the nginx recompile solution out there does not help at all. Mainly because the nginx hard-coded limit is at 2048 characters.

This is because php-fpm (instead of reading the php.ini limit) has a hard-coded limit for its error messages of 1024 characters.

Here is how you solve it
(This will encrease your limit to 8192 characters)

Download the tar ball with patches to your server and untar it. (The forum does not allow me to upload a tar ball unfortunately)
fetch "http://www.blodan.se/files/nginx-phpfpm-patches.tar.gz"
tar -zxvf nginx-phpfpm-patches.tar.gz

You now have two patches for www/nginx, two for lang/php56

Move the patches to your ports folder:
mv patch-src-core-ngx_conf_file.h /usr/ports/www/nginx/files/
mv patch-src-core-ngx_log.h /usr/ports/www/nginx/files/
mv patch-sapi-fpm-fpm-fpm_log.c /usr/ports/lang/php56/files/
mv patch-sapi-fpm-fpm-zlog.c /usr/ports/lang/php56/files/

(If you are a poudriere user obviously change path above)

Re-compile nginx and php56

Open your php.ini file (default path /usr/local/etc/php.ini) and change log_errors_max_len to 8192

Re-start nginx + php-fpm

Voila, you now receive stack traces up to 8192 characters long in your nginx-error.log
 
Back
Top