简体   繁体   English

PHP set_time_limit()不起作用,安全模式已关闭

[英]PHP set_time_limit() does not work, safemode is off

I try to disable the time limit in an PHP script by 我尝试通过以下方式禁用PHP脚本中的时间限制:

set_time_limit(0);

but it does not work; 但它不起作用; the script is still aborted after the system default of 30 seconds. 系统默认为30秒后,脚本仍将中止。 The max_execution_time setting - as displayed by phpinfo() after set_time_limit(0) - still shows 30 seconds for both Master and Local value. max_execution_time设置-在set_time_limit(0) phpinfo()之后由phpinfo()显示-对于主值和本地值仍然显示30秒。 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. 它是在Apache 2.2.15和CentOS 6.2上运行的PHP 5.3.3 (cli)

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. 如果在此设置,则时间限制不能被PHP脚本覆盖。 And the solution is to set it either in the php.ini instead of Apache config - that allows override ... 解决方案是在php.ini中而不是Apache config中设置它-允许覆盖...

max_execution_time = 30

or to define exceptions for certain directories within the apache config, eg 或在apache配置中为某些目录定义例外,例如

<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. 我还尝试使用<Files>指令为单个文件定义例外,但这没有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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