Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Problem

I've recently come across a problem with my dev version of drupal where I realised the php memory limit isn't high enough.

I've changed the main php.ini files but they seem to be ignored and I can only increase the memory limit by putting the following line into sites/default/settings.php:

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

Could there be something Drupal related which is overriding the main settings (that I'm then overriding in settings.php) as this is happening in multiple environments?

Set-Up

  • Windows 7, XAMPP:

Altered php.ini in C:/XAMPP/php/php.ini

memory_limit=500M
  • Ubuntu(10.04), Apache, PHP, MySQL

Altered php.ini in /etc/php5/apache2/php.ini

memory_limit=500M
  • Ubuntu(12.04), nginx, PHP-FastCGI, MySQL

Altered php.ini in /etc/php5/cli/php.ini (checked this was correct ini file using php --ini)

memory_limit=500M

I have a php.ini in my drupal root, but it has

memory_limit = -1

which I'm pretty sure is no limit.

share|improve this question
add comment

3 Answers

Drupal does not edit any php config settings. The memory_limit and what php.ini it is using depends on how your server is setup, there could be something else that is overriding your php.ini you are trying to set. You should use phpinfo() to find out what php.ini it is using and make sure the last occurrence of memory_limit is set to what ever you want.

share|improve this answer
 
Cheers for the confirmation. I couldn't recreate the first two instances. Not sure what I did wrong, but I did find the explanation for nginx. –  Dominic Woodman Oct 31 at 23:01
add comment

Changes to php.ini require that the server be restarted. Did you restart Apache after making those changes?

Drupal itself doesn't change memory limits; your use of ini_set in settings.php is the best way to make the change through PHP execution, but many third-party hosts will not allow that setting to be overridden to overridden.

Finally, I'd recommend setting the memory limit to 512M as that reflects how semiconductor memory stores data. There's no real functional advantage of this, though, just OCD :-)

share|improve this answer
 
That's not OCD, just good sense ;) –  Clive Oct 24 at 21:35
add comment
up vote 0 down vote accepted

Ok so a bit of digging and here are the results. The short answer for the first two configs was I couldn't replicate them. Maybe I'd forgotten to restart the server? Not sure.

The two paths I'd listed were the correct paths to change the php memory settings.

However for nginx there is a genuine answer:

  1. Although the command php --ini says /etc/php5/cli/php.ini was loaded the correct file to change was:

/etc/php5/fpm/php.ini

You then have to restart the php process manager not the server because nginx doesn't touch the php.

sudo service php5-fpm restart

Presumably the reason you have to edit /etc/php5/fpm/php.ini file is because /etc/php5/cli/php.ini is the command line php config file and only decides the config for any command line php functions I run.

Any php functions called by Drupal are processed by FPM and so use it's config file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.