I am trying to get a PHP script under local Linux Apache running without getting stopped by Apache. I am using PHP 5.5.9-1ubuntu4.4
, Apache/2.4.7 (Ubuntu)
, Ubuntu 14.04 LTS 64-bit
.
What I did so far:
In my PHP script:
ignore_user_abort(true);
set_time_limit(0);
...
foreach(...) {
...
// inside loop
usleep(1000);
...
}
In all php.ini
:
max_execution_time=3600;
Nothing of the above helped. The script stops after ~30sec. Im out of ideas. Is it possible that my script gets shut down because it runs out of memory? Best way to check that?
EDIT:
Through adding "ini_set('display_errors', 1);" I got the error Allowed memory size of 134217728 bytes exhausted
. So it is about memory, thanks for the hint how to check that.
SOLUTION:
The underlying problem turned out to be the usage of 'foreach' loops. After switching all 'foreach' loops to 'for' loops the memory usage got more stable.
To see what's causing the script to stop, add the following to the top of the page:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>