Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: settings memory_limits > 1024M does not work

For bad reasons I need to set memory_limits higher than 1 GB for a directory, but on my PHP 5.2.17 on a Debian 5.0 (Lenny) server when I use, for example, 2048M, I get only the php.ini default value (256M).

PHP runs as an Apache module, and phpinfo gives us (for the directory):

memory_limit    1024M    256M suhosin.memory_limit    0    0 

Is there a limitation due to an Apache module, or the PHP configuration? I know the server only has 4 GB of RAM. It's just a special script.

like image 800
Cédric Girard Avatar asked Feb 14 '12 11:02

Cédric Girard


Video Answer


1 Answers

How are you trying to set the memory limit? phpinfo() shows current PHP reserved memory limit, and this is what is available due to php.ini having that set as a memory limit.

Writing this to the Apache .htaccess file in your script directory might work if your server supports setting PHP commands through .htaccess:

php_value memory_limit 2048M 

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'); 

If this doesn't work and .htaccess also doesn't work, then you need to contact the server administrators.

like image 82
kingmaple Avatar answered Sep 21 '22 00:09

kingmaple