Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX Sierra - how to increase PHP memory limit correctly?

I need to increase the memory limit for PHP on the command line so I can use Composer.

Output of php -i | grep memory_limit

memory_limit => 256M => 256M

Output of php --ini

Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File:         /usr/local/php5/lib/php.ini
Scan for additional .ini files in: /usr/local/php5/php.d
Additional .ini files parsed:      /usr/local/php5/php.d/10-extension_dir.ini,
/usr/local/php5/php.d/20-extension-opcache.ini,
/usr/local/php5/php.d/40-openssl.ini,
/usr/local/php5/php.d/50-extension-apcu.ini,
/usr/local/php5/php.d/50-extension-curl.ini,
/usr/local/php5/php.d/50-extension-gmp.ini,
/usr/local/php5/php.d/50-extension-igbinary.ini,
/usr/local/php5/php.d/50-extension-imap.ini,
/usr/local/php5/php.d/50-extension-intl.ini,
/usr/local/php5/php.d/50-extension-mcrypt.ini,
/usr/local/php5/php.d/50-extension-memcache.ini,
/usr/local/php5/php.d/50-extension-memcached.ini,
/usr/local/php5/php.d/50-extension-mongo.ini,
/usr/local/php5/php.d/50-extension-mssql.ini,
/usr/local/php5/php.d/50-extension-oauth.ini,
/usr/local/php5/php.d/50-extension-pdo_dblib.ini,
/usr/local/php5/php.d/50-extension-pdo_pgsql.ini,
/usr/local/php5/php.d/50-extension-pgsql.ini,
/usr/local/php5/php.d/50-extension-propro.ini,
/usr/local/php5/php.d/50-extension-raphf.ini,
/usr/local/php5/php.d/50-extension-readline.ini,
/usr/local/php5/php.d/50-extension-redis.ini,
/usr/local/php5/php.d/50-extension-solr.ini,
/usr/local/php5/php.d/50-extension-ssh2.ini,
/usr/local/php5/php.d/50-extension-twig.ini,
/usr/local/php5/php.d/50-extension-uploadprogress.ini,
/usr/local/php5/php.d/50-extension-xdebug.ini,
/usr/local/php5/php.d/50-extension-xhprof.ini,
/usr/local/php5/php.d/50-extension-xsl.ini,
/usr/local/php5/php.d/60-extension-pecl_http.ini,
/usr/local/php5/php.d/99-liip-developer.ini

So I edit /usr/local/php5/lib/php.ini but it's always 256MB...

Restarted Apache, but it's cli, but still no success.

like image 313
Codium Avatar asked Mar 17 '17 16:03

Codium


3 Answers

Maybe you should find out where php.ini is

sometimes this won't do:

php -i | grep php.ini   # turns out I just can't edit /etc/php.ini even when I'm root

then you can try this:

locate php.ini  # turns out it's here: /private/etc/php.ini

finally, edit /private/etc/php.ini with sudo

sudo vim /private/etc/php.ini 

save the file with

:wq!

job done.

like image 188
Randy Lam Avatar answered Oct 17 '22 02:10

Randy Lam


One of the other included files has a memory_limit directive. Use this command to find which one:

grep memory_limit /usr/local/php5/php.d/*

The "Additional .ini files parsed" are parsed later, and will override settings in the main php.ini.

like image 14
miken32 Avatar answered Oct 17 '22 02:10

miken32


I found out that you need to change the memory limit in this file :

/usr/local/etc/php/*your php version*/conf.d/php-memory-limits.ini

Worked like a charm after modifying this file.

like image 2
Hadrien Lepoutre Avatar answered Oct 17 '22 01:10

Hadrien Lepoutre