简体   繁体   中英

PHP set_time_limit() does not work, safemode is off

I try to disable the time limit in an PHP script by

set_time_limit(0);

but it does not work; the script is still aborted after the system default of 30 seconds. The max_execution_time setting - as displayed by phpinfo() after set_time_limit(0) - still shows 30 seconds for both Master and Local value. It also shows that Safe Mode is Off.

Do you have any idea what goes wrong? It's PHP 5.3.3 (cli) running on CentOS 6.2 with Apache 2.2.15.

I was able to solve the problem now. The reason was

php_admin_value max_execution_time "30"

... within the virtual host configuration. If set there, the time limit cannot be overridden by a PHP script. And the solution is to set it either in the php.ini instead of Apache config - that allows override ...

max_execution_time = 30

or to define exceptions for certain directories within the apache config, eg

<Directory /path/to/my/scripts>
  php_admin_value max_execution_time "600"
</Directory>

I also tried to define exceptions for single files using the <Files> directive, but that did not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM