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

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

问题描述

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



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

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

在settings.php(每个请求中都包含的文件),但这会导致内部服务器错误500.如果我拿出来,我得到这个错误:

 致命错误:允许的内存大小为33554432字节耗尽(试图分配19456个字节)... 

侧面问题:19456小于33554432.为什么说允许的大小用尽?



我也尝试将其放在.htaccess:

  php_value memory_limit 128M 

这没有任何效果。

解决方案

您收到的错误消息:


允许内存大小为33554432字节
耗尽(尝试分配19456
字节)


表示您正在尝试分配超过您允许使用33554432个字节;即32 MB:

 ; 33554432/1024/1024 
32

表示失败的分配是PHP尝试分配19千字节;但是,已经有近32MB的分配了 - 这些分配没有失败,因为它们的总数不到32 MB。



19456字节部分错误信息不是真正相关的:相关的是您的 memory_limit 设置为32 MB。





考虑到 memory_limit 是某种安全性,您的托管服务提供商可以让您更改其价值,这将是奇怪的。 。



如果您是共享托管服务器,那意味着服务器上的任何人都可以获得任意数量的内存,哪些不太适合其他用户在同一个服务器上!



BTW:32MB实际上是一个非常合理的价值 - 我从来没有看到配置为允许超过32 MB的网络应用程序...而PHP 5.2的默认值似乎是16 MB,根据手册

(我已经和Drupal合作了几个月)





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

该手册没有看到太多,但是在 max_execution_time 指令:


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


我认为关于 memory_limit 也是如此。无论如何,这似乎是合乎逻辑的。


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.)

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

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

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)...

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

I also tried putting this in on .htaccess:

 php_value memory_limit                 128M 

This had no effect.

解决方案

The error message you are getting :

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

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

; 33554432/1024/1024
        32

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.

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.


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 !

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)


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.

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

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.

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

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

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