更改了 php.ini 中 max_execution_time 的设置,Drupal 仍然有问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13686900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:53:42  来源:igfitidea点击:

Changed setting in php.ini for max_execution_time, Drupal still having problems

drupaltimeoutphp

提问by Cecil Rodriguez

Ok, I am trying to do some work for a client. Currently we're just trying to do a kludgy fix for a custom function another developer created, which exports a CSV of all of their contacts.

好的,我正在尝试为客户做一些工作。目前,我们只是试图为另一个开发人员创建的自定义功能做一个笨拙的修复,该功能导出他们所有联系人的 CSV 文件。

As they've added more contacts, the function takes longer, and it requires more memory (we've had to up their memory limit from 128M to 256M already, and now up to 512M).

随着他们添加更多联系人,该功能需要更长的时间,并且需要更多内存(我们不得不将他们的内存限制从 128M 提高到 256M,现在达到 512M)。

Anyway, I'm trying to run the CSV exporter, and I'm getting the following errors, on different runs:

无论如何,我正在尝试运行 CSV 导出器,但在不同的运行中出现以下错误:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/readyby2/public_html/includes/module.inc on line 19

Fatal error: Maximum execution time of 30 seconds exceeded in /home/readyby2/public_html/sites/all/modules/contrib/views/modules/field/views_handler_field_field.inc on line 0

and every now and again I am getting an Internal Server Error 500

我时不时地收到内部服务器错误 500

Note, this function HAS worked before - and I have seen it work.

请注意,此功能以前有效 - 我已经看到它有效。

Now, as far as I can tell, this means that I need to change the maximum execution time setting in php.ini.

现在,据我所知,这意味着我需要更改 php.ini 中的最大执行时间设置。

There is a php.ini file outside of the /public_htmlfolder (which is where the files for the Drupal install are kept) and I've modified that setting - but still get all of the errors above. I've changed it to 60, 90, and 0, respectively, no change.

文件/public_html夹外有一个 php.ini 文件(这是保存 Drupal 安装文件的位置),我已经修改了该设置 - 但仍然出现上述所有错误。我已经分别把它改成了 60、90 和 0,没有变化。

Is there anywhere else where timeout settings are set for a Drupal install? Am I finding the right php.ini file? I'm not seeing one in the /public_htmldirectory, or any others.

是否还有其他地方为 Drupal 安装设置超时设置?我找到了正确的 php.ini 文件吗?我在/public_html目录或任何其他目录中都没有看到。

How can I solve this issue? I've already upped the memory limit (could the server error imply that there isn't enough memory available on the server to perform this function?)

我该如何解决这个问题?我已经提高了内存限制(服务器错误是否意味着服务器上没有足够的内存来执行此功能?)

Any advice or help would be useful.

任何建议或帮助都会有用。

As an FYI, this is in Drupal 7. PHP version is 5.x (I don't remember the exact one, think it is 5.1, can find out if necessary).

仅供参考,这是在 Drupal 7 中。PHP 版本是 5.x(我不记得确切的版本,认为是 5.1,如果需要可以找到)。

回答by Jonathan Rowny

Where the correct php.ini is, is going to depend a lot on your hosting environment but you can quickly get around it by using either ini_setor the set_time_limitfunction on the script.

正确的 php.ini 在哪里,将在很大程度上取决于您的托管环境,但您可以通过使用ini_setset_time_limit脚本上的函数快速解决它。

You can do the ini set in settings.php but then it will be global for the whole site.

您可以在 settings.php 中执行 ini 设置,但随后它将是整个站点的全局设置。

ini_set('max_execution_time', 120);to settings.php

ini_set('max_execution_time', 120);到 settings.php

or in your script set_time_limit ( 120 )this doesn't work if PHP safemode is on!

或者在您的脚本set_time_limit ( 120 )中,如果 PHP 安全模式打开,这将不起作用!

回答by arkascha

Usually the php.ini file is somewhere like /etc/php5/apache/php.inior similar. Maybe just /etc/php.inion more simple setups.

通常 php.ini 文件是类似/etc/php5/apache/php.ini或相似的地方。也许只是/etc/php.ini在更简单的设置上。

You might want to consult your software management system: $> rpm -ql php5or the apt alternative, if you on a debian based system. That lists you the files contained in the package. The php.ini file should be amongst them. Depending on your distribution you might also have to look at the package apache-mod_php5or similar. Search for php inside your package management, for example with $> rpm -q --whatprovides /usr/bin/php5or $> rpm -qa | grep -i php.

$> rpm -ql php5如果您使用的是基于 debian 的系统,您可能需要咨询您的软件管理系统:或 apt 替代方案。这会列出包中包含的文件。php.ini 文件应该在其中。根据您的发行版,您可能还需要查看软件包apache-mod_php5或类似内容。在包管理中搜索 php,例如使用$> rpm -q --whatprovides /usr/bin/php5$> rpm -qa | grep -i php

Call phpinfo()within the drupal environment. In the output php specifies which php.inifile has been parsed.

phpinfo()在 drupal 环境中调用。在输出中 php 指定哪个php.ini文件已被解析。

回答by Cobra_Fast

Another options is to add the following to drupal's .htaccess:

另一种选择是将以下内容添加到 drupal 中.htaccess

php_value max_execution_time 0

回答by Thomas Musa

You can always try (in settings.php of you sites (sites/default/settings.php) see if you got rights write it.

您可以随时尝试(在您站点的 settings.php (sites/default/settings.php) 中查看您是否有权编写它。

ini_set('memory_limit', '256M');

ini_set('memory_limit', '256M');

it's overwride php.ini. But I don't think you can fix it by increase memory(you can't increase your limit every time you got memory problem). You must find what produce this reach limit (infinite boucle, too much result...) You can always use Views module and csv export to make a good csv with a good views :D Just think to overwride pager for csv.

它覆盖了 php.ini。但我不认为你可以通过增加内存来解决它(你不能在每次遇到内存问题时增加你的限制)。您必须找到产生此到达限制的原因(无限圆球,结果太多...)您始终可以使用视图模块和 csv 导出来制作具有良好视图的良好 csv :D 只想覆盖 csv 的寻呼机。