Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MacOS Laravel Valet increase memory_limit

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 ?

like image 494
ZecKa Avatar asked Dec 14 '19 14:12

ZecKa


People also ask

What is Php_admin_value Memory_limit?

php_admin_value[max_execution_time] = 120. Set the Memory Limit. The maximum memory size that a PHP script can allocate can be easily set. In the following example, the maximum memory size is set to 96 MB: php_admin_value[memory_limit] = 96M.

How do I set laravel memory limit?

We can temporarily increase the memory limit using this function: // Temporarily increase memory limit to 256MB ini_set('memory_limit','256M'); In my case, I needed more than 128MB of memory, so I conveniently increased it to 256MB. It depends on your usage and your hardware.

How do I increase memory limit in Ubuntu?

To increase the PHP memory limit setting, edit your PHP. ini file. Increase the default value (example: Maximum amount of memory a script may consume = 128MB) of the PHP memory limit line in php. ini.


1 Answers

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?

like image 107
ZecKa Avatar answered Oct 10 '22 11:10

ZecKa