What errors are getting sent to the Apache error log and to STDERR when the script pukes?
Maybe you could put up some relevant code bits which you think might be causing the problem?
Without either of these, we really can't help. You'll just have to pick one:
1 2