Kontakt aufnehmen
Server 1 Min. Lesezeit · 07/2021

NGINX, PHP-FPM und memory_limit

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

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 fast_cgi_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;
}
Teilen
LinkedIn Facebook

Brauchen Sie mehr als einen Artikel?

Melden Sie sich unverbindlich – ein paar Sätze dazu, worum es geht, genügen.

Weiterlesen

Ähnliche Artikel

Weitere Notizen aus Betrieb und Entwicklung.

Gesamter Ratgeber