NGINX, PHP-FPM and memory_limit
Setting the PHP memory limit in the NGINX and PHP-FPM configuration
In PHP-FPM, memory_limit is set to 128MB by default. If you need to change this limit, you can set the desired value using the fast_cgi_param directive:
fastcgi_param PHP_VALUE "memory_limit = 1G";
For a Symfony application, the configuration can look like this, for example:
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param PHP_VALUE "memory_limit = 1G";
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}