Increase CLI php memory limit on OSX

When running MAMP or MAMP Pro on a Mac OSX (this is on version 10 Yosemite) you will notice that PHP executed from the command line (CLI) will use  different PHP settings than your website. In this case, OSX is using its own built-in apache server and php settings, not the ones defined by your MAMP setup.

You can easily change this though, as long as you know which php.ini to change.

First, check your memory limit, by running the following command on your SSH shell or local terminal:

php -i | grep memory

This will output something like the following:

memory_limit => 128M => 128M

Now, let's see which php.ini is used:

php -i | grep php.ini

This might return something like this:

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

It might also say on a second line which configuration file is loaded, but if that is not the case, OSX is using de default php.ini which is located in /etc/private/php.ini.default. In order to override the 128MB you will need to copy that file to the Path specified above, and change it:

cp /etc/private/php.ini.default /etc/php.ini

Note #1: You might have to use the sudo command to perform these actions.

Note #2: If there isn't a default php.ini at /etc/private, try the locate php.ini command in order to get a list of possible locations in your system.

Then, edit this file and change the memory_limit value to your preferred value:

nano /etc/php.ini

Then restart your apache (and thus reinitialize php) with this command, or reboot.

apachectl restart

That should do the trick.

About

This is the company blog of
Drupal specialist Merge.nl

We are located in Breda (Netherlands) and build websites using Drupal. More about us.

Content on this blog is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.

Creative Commons License

Recent Comments

Social