PHP:设置memory_limits> 1024M不起作用 [英] PHP : settings memory_limits > 1024M does not work
问题描述
出于不利的原因,我需要为目录设置memory_limits高于1G,但是在Lenny服务器上的PHP 5.2.17上,例如当我放入2048M时,我仅得到php.ini默认值(256M).
For bads reasons I need to set memory_limits higher than 1G for a directory, but on my PHP 5.2.17 on Lenny server when I put for example 2048M I get only the php.ini default value (256M).
PHP作为apache模块运行,phpinfo给我们(用于目录)
PHP run as an apache module, phpinfo give us (for the directory)
memory_limit 1024M 256M
suhosin.memory_limit 0 0
由于apache模块或PHP conf是否存在限制?我知道服务器只有4G的RAM,这只是一个特殊的脚本.
Is there a limitation due to apache module, or PHP conf? I know the server only have 4G of RAM, it's just a special script.
推荐答案
您如何尝试设置内存限制? phpinfo()显示当前PHP保留的内存限制,由于php.ini将其设置为内存限制,因此可以使用此功能
How are you trying to set the memory limit? phpinfo() shows current PHP reserved memory limit, this is what is available due to php.ini having that set as a memory limit
如果您的服务器支持通过.htaccess设置PHP命令,则可以将其写入脚本目录中的Apache .htaccess:
Writing this to Apache .htaccess in your script directory might work, if your server supports setting PHP commands through .htaccess:
php_value memory_limit 2048M
由于可能会关闭用于设置PHP值的.htaccess命令.然后,您也可以从PHP代码尝试此操作:
Since it may be possible that .htaccess commands for setting PHP values are turned off. Then you can also try this from PHP code:
ini_set('memory_limit', '2048M');
如果这不起作用,.htaccess也不起作用,那么您需要联系服务器管理员.
If this doesn't work and .htaccess also doesn't work, then you need to contact server administrators.
这篇关于PHP:设置memory_limits> 1024M不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!