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?


  • Windows 7, XAMPP:

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

  • Ubuntu(10.04), Apache, PHP, MySQL

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

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


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

memory_limit = -1

which I'm pretty sure is no limit.

4 Answers 4


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.

  • 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. Oct 31, 2013 at 23:01

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

  • That's not OCD, just good sense ;)
    – Clive
    Oct 24, 2013 at 21:35

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 is:


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

sudo service php5-fpm restart

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.

Any php functions called by Drupal are processed by FPM and so use the php-fpm config file.


How to deal with PHP memory not being applied.

  1. Check if you're editing the right file by going to Drupal page and you can find the right location of your PHP config file in:

    Reports -> Status report -> PHP: more information -> Loaded Configuration File: /etc/.../.../php.ini

  2. Look for memory_limit on the same page.

  3. Make sure you placed the right value (e.g. memory_limit = 512M).

  4. Restart your HTTP server, for instance:

     sudo apache2ctl graceful

For drush, just run: drush status and it would show you the command-line configuration (CLI, which could be different from GUI):

$ drush status | grep PHP
 PHP executable                  :  /usr/bin/php          
 PHP configuration               :  /etc/php5/cli/php.ini 
 PHP OS                          :  Linux                 

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