I've been searching for why for the past 2 days and I tried a lot of solutions on the internet and here on stack.
I have a dedicated VM with ubuntu 16.04 with apache2 -> Server version: Apache/2.4.18 (Ubuntu) with the default php instalation: php -v
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS ).
phpinfo()
PHP Version 7.0.8-0ubuntu0.16.04.2
Recently I noticed that the scripts can run for forever, there is no timeout limit enforced.
I did a phpinfo() to get the php.ini file used. I checked inside the php.ini the following parameters:
default_socket_timeout = 60
session.gc_maxlifetime = 1440
max_execution_time = 30
max_input_time = 60
I even set them to 3 seconds (max_execution_time, max_input_time and default_socket_timeout), restarted apache, but with no results.
The following code for example (and it's not the only one i tried) doesn't time out, it runs until it finishes:
echo "<br>initial max_execution_time: " . ini_get('max_execution_time') ;
print_r(set_time_limit(2));
echo " - set_time_limit
";
echo "<br>initial max_execution_time: " . ini_get('max_execution_time') ;
ini_set('max_execution_time', '1');
echo "<br>initial max_execution_time: " . ini_get('max_execution_time') ;
ini_set('default_socket_timeout','1');
echo "<br>ini_get('default_socket_timeout')". ini_get('default_socket_timeout');
//phpinfo();
set_time_limit(1);
$i = 0;
while(++$i < 1000000001){
if($i % 100000 == 0){
echo $i / 100000, "<br/>
";
}
}
echo "done.<br/>
";
The output is telling me that the timeouts are correctly set, but like I said, the script is running for 32seconds without being killed.
Any ideas why the timeouts are not applied?
Thanks