MacOS Laravel Valet increase memory_limit
Asked Answered
C

5

13

I try to increase the memory_limit of php with Laravel valet.

What I see:

With phpinfo() I see:

  • memory_limit 128M
  • Configuration File (php.ini) Path /usr/local/etc/php/7.4
  • Loaded Configuration File /usr/local/etc/php/7.4/php.ini
  • Scan this dir for additional .ini files /usr/local/etc/php/7.4/conf.d Additional .ini files parsed /usr/local/etc/php/7.4/conf.d/ext-opcache.ini, /usr/local/etc/php/7.4/conf.d/php-memory-limits.ini

What I already do

  • I update php.ini and php-memory-limit.ini to edit the memory_limit from 128M to 256M: memory_limit = 256M

  • Then I have run the following command: valet restart

  • I also try to edit /usr/local/etc/php/7.4/php-fpm.d/valet-fpm.conf to add php_admin_value[memory_limit] = 256M

  • But after that the memory_limit stuck to 128M ( with phpinfo() )

the following command return me 256M: php -i | grep memory_limit

Any idea how to increase this value ?

Costplus answered 14/12, 2019 at 14:38 Comment(1)
I just modify this file , it works: /usr/local/etc/php/7.4/conf.d/php-memory-limits.iniRumple
C
26

I found a solution but I didn't understand why it works, but not what I did before. If anyone has an explanation, I'm interested.

I edit /usr/local/etc/php/7.4/php-fpm.d/valet-fpm.conf and replace following line php_admin_value[memory_limit] = 128M
With this line
php_admin_value[memory_limit] = 256M

Then I run the following command:

valet restart
brew services restart [email protected]

With just one of these two commands it doesn't work.
However valet restart is supposed to restart php, right?

Costplus answered 14/12, 2019 at 16:18 Comment(2)
Thank you for this! I don't understand why this value is determining the memory_limit either. I couldn't get those changes to be seen with either of those commands actually. I went into Activity Monitor and quit/force quit all php-fpm processes, then was able to see the changes.Morey
Wow, thanks for the explanation. I've been dealing with this for weeks, not documented anywhere. I had the exact same problem with the exact same stack. Saving this for future reference.Jacquerie
A
10

One solution worked with me, editing the file:

/usr/local/etc/php/7.2/conf.d/php-memory-limits.ini

And change the value memory_limit, save and run the command (to make sure it was changed):

php -r "echo ini_get('memory_limit').PHP_EOL;"

Then, restart Valet:

valet restart

Alsworth answered 10/4, 2021 at 21:53 Comment(2)
this should be the answerSmattering
This is the answerBornholm
Z
7

On Mac silicon it's lying there: /opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini

And make sure you restart valet next: valet restart

Zombie answered 21/3, 2023 at 14:14 Comment(0)
K
3

Check the memory limit using

php -r "echo ini_get('memory_limit').PHP_EOL;"

Then you can check the config file loaded

php --ini

Sometimes there are more than one, so please check all the config files.

Kishke answered 11/2, 2021 at 4:27 Comment(0)
Z
1

I am using Mac intl chip. And in my case file is /usr/local/etc/php/7.4/php-fpm.d/www.conf and further changes i did same as mentioned right answer.

Thank you so much for answer.

"I found a solution but I didn't understand why it works, but not what I did before. If anyone has an explanation, I'm interested.

I edit /usr/local/etc/php/7.4/php-fpm.d/valet-fpm.conf and replace following line php_admin_value[memory_limit] = 128M With this line php_admin_value[memory_limit] = 256M

Then I run the following command:

valet restart brew services restart [email protected] With just one of these two commands it doesn't work. However valet restart is supposed to restart php, right?"

Zippora answered 2/9, 2022 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.