增加 PHP 内存限制(Apache、Drupal6) [英] Increase PHP Memory limit (Apache, Drupal6)

查看:25
本文介绍了增加 PHP 内存限制(Apache、Drupal6)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在共享托管服务器上运行 Drupal 安装.(我只是订阅了一个提供商 - 我不拥有这个盒子.)

I'm trying to run a Drupal installation on a shared hosting server. (I'm just subscribing to a provider - I don't own the box.)

我需要增加我的 Apache 服务器的 PHP 内存限制.我试过了

I need to increase the PHP memory limit for my Apache server. I have tried

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

在 settings.php(包含在每个请求中的文件)中,但这会导致内部服务器错误 500.如果我将其取出,则会出现此错误:

in settings.php (a file that is included in every request), but this causes Internal Server Error 500. If I take it out, I get this error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes)...

附带问题:19456 小于 33554432.为什么说允许的大小已用完?

Side question: 19456 is less than 33554432. Why is it saying that allowed size is exhausted?

我也试过把它放在 .htaccess 上:

I also tried putting this in on .htaccess:

 php_value memory_limit                 128M 

这没有效果.

推荐答案

您收到的错误消息:

允许的内存大小为 33554432 字节用尽(试图分配 19456字节)

Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes)

表示您尝试分配的字节数超过了允许使用的 33554432 字节;即 32 MB :

Indicates that you are trying to allocate more than the 33554432 bytes you are allowed to use ; ie 32 MB :

; 33554432/1024/1024
        32

表示分配失败是在 PHP 尝试分配 19 KB 时;但是已经分配了将近 32MB -- 这些分配没有失败,因为它们的总数不到 32 MB.

It indicates that the allocation that failed was when PHP tryied to allocate 19 Kbytes ; but there had already been almost 32MB allocated -- those allocations did not fail, as their total was less than 32 MB.

错误消息的19456 字节"部分并不是真正相关的:相关的是您的 memory_limit 设置为 32 MB.

The "19456 bytes" part of the error message is not what is really relevant : what is relevant is that your memory_limit is set at 32 MB.


考虑到 memory_limit 是某种安全性,您的托管服务提供商允许您更改其值会很奇怪...


Considering the memory_limit is some kind of security, it would be strange that your hosting provider allows you to change its value...

如果您在共享主机上,这意味着服务器上的任何人都可以获得他们想要的任何内存量...这对同一服务器上的其他用户来说不会那么好!

If you are on shared hosting, it would mean that anyone on the server could get any amount of memory they want... Which would not be that nice for the other users on the same server !

顺便说一句:32MB 实际上是一个相当合理的值——我从未见过将服务器配置为允许超过 32 MB 的 Web 应用程序......并且 PHP 5.2 的默认值似乎是 16 MB,根据手册.
(我已经与 Drupal 合作了几个月)

BTW : 32MB is actually a quite reasonable value -- I've never seen a server configured to allow more than 32 MB for a web application... And the default value for PHP 5.2 seems to be 16 MB, according to the manual.
(And I've been working with Drupal for a couple of months)


关于错误500,我没有很多想法......一种可能性可能是safe_mode 已激活,并且不允许在执行时设置 memory_limit.


About the error 500, I don't have a lot of ideas... One possibility might be that the safe_mode is activated, and that it doesn't allow setting the memory_limit at execution time.

手册并没有看到太多关于这一点的信息,但是max_execution_time 指令:

The manual doesn't see to say much about that, but there is a bit of information under the max_execution_time directive :

您无法更改此设置ini_set() 在安全模式下运行时.唯一的解决方法是关闭安全模式或更改时间php.ini 中的限制.

You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.

我想 memory_limit 也是如此;无论如何,这似乎是合乎逻辑的.

I suppose the same is true about memory_limit ; it would seem logical, anyway.

这篇关于增加 PHP 内存限制(Apache、Drupal6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆