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

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.