My script compares 2 source trees, creates a map of possible changed files, compares MD5 hashes and creates a diff-package.
After 28000-29000 files, PHP terminates t
Try setting max_input_time = -1 in php.ini, or using set_time_limit(-1). That worked for me without rebuilding PHP.
max_input_time = -1
php.ini
set_time_limit(-1)
This article explains it nicely.