How do I increase PHP memory limit on Ubuntu 14.04


I am using a 1GB Droplet with current kernel: Ubuntu 14.04 x64 vmlinuz-3.13.0-24-generic (1221)

Using phpinfo() I have identified the currently loaded php.ini file, and have updated the memory_limit attribute to 512M from 128.

This file is /etc/php5/fpm/php.ini

Despite making this change (and of course restarting nginx and php5-fpm services - as well as rebooting the entire server after each change), the value shown in phpinfo() remains at 128M

Other things I’ve tried (again, have rebooted/restarted services):

  • Adding the following values to /etc/php5/fpm/php-fpm.conf
php_admin_value[memory_limit] = 512M
php_value[memory_limit] = 512M
  • Adding a user.ini file in /etc/php5/fpm/conf.d/ (as this directory is scanned for other config files) - and adding the memory_limit with 512M memory

  • Editing /etc/php5/cli/php.ini to the same 512M value, even though this file isn’t being used.

  • Adding a php.ini file with the updated memory_limit value inside the root of the web site’s directory

I am absolutely stumped, and if someone can offer any insights or further troubleshooting steps, I would be greatly appreciative!



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, all

You can create a php info file in order to check the current values and check which is the php.ini file in use. Create the following file in your public_hmtl folder - phpinfo.php and put the following code inside it:


You can also use the following command in order to find the location of the php.ini file:

php -i | grep php.ini

The output will be:

Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini

Then check for the current value of memory_limit you can also check which is the configuration file - php.ini that is currently used and apply the changes there (if the site using the global php.ini file and you change the values for these settings this will make the changes globally for all sites). Ideally you would like to have the following values:

memory_limit = 256M

You also need to restart your web server in order the changes to take effect.

Hope that this helps! Regards, Alex

I found it was because memory_limit appeared multiple times in the php.ini 😑 Not sure why - the whole contents repeated 3 times in the one file.

Maybe it’s too late but just for reference as I wasted three hours trying to increase the memory limit for Magento.

Turns out that this was set in the .htaccess file for the virtual host.

Hi Enigma

Wow - great tips; thanks for sending such a detailed list.

So, to answer your questions in order:

  • Yep, I put the other ini files back to default.
  • Item I downloaded another php.ini from a working droplet that uses the same image - no luck.
  • No luck with .htaccess
  • No luck with post_max_size
  • I’m not sure if you mean changing the post_max_size will have an impact on memory_limit, but when I change the post_max_size value in the same PHP.ini file, it is reflected in phpinfo()
  • Interestingly, no - php -i returns /etc/php/cli/php.ini - however I tried editing this file previously with no luck.
  • No other instances of memory_limit
  • I’ve checked the logs, and they look clear - other than a recurring notice:

[17-May-2015 16:44:57] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful

  • I couldn’t find much information as to where I should look for this extension so I tried to uninstall it, and I was told that it didn’t exist.
  • No luck
  • Yes I tried lowering to 64M - no change
  • My PHP version is 5.5.9-1ubuntu4.9

So other than point 6 - where the php.ini files don’t reconcile, it all seems to check out OK. Perhaps I have to check out the suhosin stuff more, but as I said - I didn’t have much luck finding out how to configure this. Any other thoughts or pointers are of course welcomed!


Hi smarterdigitalltd,

What version of php are you using exactly?

I’m not sure what the problem is, but I thought the following might help:

  • If you’re making modification to many php.ini, just stick to the one phpinfo() shows.
  • If there is a syntax error within php.ini, it might not parse the rest of th file.
  • It seems possible to change the memory limit from .htaccess
  • Maybe increase post_max_size?
  • Compare php -i with phpinfo()
  • Look for other instances of memory_limit inside php.ini
  • Is it possible to check some sort of php logs to look for potential errors?
  • The suhosin extension is known to limit memory settings. Check if you use it.
  • Try init_set e.g. ini_set("memory_limit","256M");
  • Try lowering it first, to see if there’s any changes.

Hope this helps.