Zum Inhalt springen
iD-SIGN
Kontakt aufnehmen

NGINX, PHP-FPM und memory_limit

Das Memory Limit für PHP in der Konfiguration von NGINX und PHP-FPM einstellen

1 Min. Lesezeitveröffentlicht 7/2021

In PHP-FPM ist memory_limit standardmäßig auf 128MB gesetzt. Wenn dieses Limit geändert werden muss, lässt sich der gewünschte Wert über die Direktive fastcgi_param setzen:

nginx
fastcgi_param PHP_VALUE "memory_limit = 1G";

Für eine Symfony-Anwendung kann die Konfiguration dann zum Beispiel so aussehen:

nginx
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;
}

Schlagwörter Server, PHP, Nginx

Teilen LinkedIn Facebook

Brauchen Sie mehr als einen Artikel?

Ein paar Sätze zu Ihrem Anliegen genügen.