Context
I am trying to deploy a fresh Symfony 3.4.10 application. It's the first time I deploy a Symfony application. It runs well in dev environment using the built-in php server.
I use nginx as webserver and php-fpm.
Problem
When I try to reach my application, an error is thrown in my logs saying:
2018/05/25 02:32:03 [error] 15819#15819: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/my-project/application/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107 PHP message: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/my-project/application/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107" while reading response header from upstream, client: xx.xx.xx.xx, server: preprod.my-website.fr, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "preprod.mywebsite.fr"
The page I try to load is just a connection form.
I allocated 1024MB in my php.ini
, thinking it was because the app needed more RAM on the first call.
What seems really strange is that the log is telling the memory size is exhausted but the amount the app was trying to allocate is really low: 20480 bytes
allocated for a maximum amount of 1073741824 bytes
, I don't understand why it fails and how to solve this.
My website nginx configuration:
server {
listen 443;
listen [::]:443;
server_name preprod.my-website.fr;
root /var/www/my-project/application/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/my-project_error.log;
access_log /var/log/nginx/my-project_access.log;
# SSL configuration
ssl on;
ssl_certificate /etc/letsencrypt/live/preprod.my-website.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/preprod.my-website.fr/privkey.pem;
}
server {
listen 0.0.0.0:80;
server_name preprod.my-website.fr;
rewrite ^ https://$host$request_uri? permanent;
}