I've edited every single php.ini on my Mac (at least all the ones found by "locate") and still can't seem to increase the memory_limit directive for PHP.

I'm using MAMP PRO and running PHP scripts in the terminal.

How to solve this?

7 Answers 7


Instead of guessing which php.ini you need to alter, run this command to locate the file:

php -r 'phpinfo();' | grep 'php.ini'

Even though I use MAMP PRO, by default my command-line PHP commands are not executed using their copy of PHP. In my case it says the file is found at /etc/php.ini

Once you have located the file, follow the instructions on all of the other answers to bump the memory_limit setting:

memory_limit = 256M
  • 1
    I had to fist cp the default file: cp /etc/php.ini.default /etc/php.ini Commented Jan 22, 2018 at 23:56

From http://drupal.org/node/66187 (drupal may be irrelevant for your needs, but their site had a good explanaton - wanted to source it for you, and give credit to them)

By default, MAMP has the memory limit that a script can use set at 8MB, which is the PHP default. Looking at PHP's php.ini-recommended file, this memory limit is normally set at 128MB. To adjust this amount, open the php.ini file in a text editor and change the following line (approximately on line 232):

memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

PHP.ini file locations:

In MAMP PRO, don't alter the file directly since it will be recreated at each server start. Please edit the appropriate template (menu File > Edit template > ...) instead.

Even with larger PHP memory limits you can get timeout errors trying to import large Drupal databases into MySQL. These issues are discussed at length elsewhere with regards to the cache and views cache. Generally the solution is to empty the Drupal cache before importing/exporting databases to/from MySQL.

  • No go, those limits were already at 128MB...
    – Alex Weber
    Commented Nov 22, 2011 at 1:31
  • hmm. you have pro...try editing the template instead. Apparently the php.ini file gets recreated each time. Instructions here: documentation.mamp.info/en/mamp-pro/how-tos/… That work? What are you running on the mamp server?
    – dmg
    Commented Nov 22, 2011 at 2:37
  • still nothing, every single php.ini file i can find (and templates too) are all with 128MB but php -r "phpinfo();" | grep memory_limit still returns memory_limit => 8M => 8M
    – Alex Weber
    Commented Nov 22, 2011 at 4:51

For me, I did the following:

Edit the /Applications/MAMP/conf/php5.4.4/php.ini



to be:

memory_limit = 128M      ; Maximum amount of memory a script may consume (8MB)

Then in finder simply make the php.ini and php.ini.temp read only for all users. This way, MAMP cannot overwrite it with default files. Restart the server and check your phpinfo.

  • the simplest things go unnoticed! Thanks for this idea! Commented Dec 27, 2012 at 17:57

After messing around for a while a found something that worked for me:

# backup original php.ini
sudo mv /usr/bin/php /usr/bin/php.bkp

# create a symlink from MAMP's php.ini in /usr/bin directory
# (I use 5.2, change the path for 5.3)
sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/php /usr/bin/php



Quick and dirty way to do this is to set it as argument when calling your script.


php -d memory_limit=512M myScript.php 

if you use Homebrew, your php settings are at /usr/local/etc/php/<php version>


If you have Opcache on in Mamp Pro it will not you get the proper setting... stop it, restart your Mamp Pro server...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .