Increasing PHP's memory limit

By default, PHP will limit itself to using 128MB, which may be exceeded depending on your tasks. In some cases, it's easy to pass along a new memory limit to one-off commands using the following command, replacing -1 with the new memory limit (e.g 512M, 1G. -1 will remove any memory limit and could result in consuming all the memory):

php -d memory_limit=-1 <command>

Sometimes, this isn't an ideal solution, and the memory limit should be persisted throughout the job. In this instance, it's easy to set a new memory limit by creating a new memory limit configuration file using the following command, which will ensure PHP runs with the increased memory each time it executes (again, replacing -1 with the actual limit you would like):

echo 'memory_limit = -1' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
Was this article helpful?
4 out of 5 found this helpful

Comments

0 comments

Article is closed for comments.