Symfony2 Nginx Configuration File

Published on Author craigzearfossLeave a comment
server {
    listen 80;

    server_name PROJECT_DOMAIN;
    root /www/PROJECT_DOMAIN/web;

    # strip app.php/ prefix if it is present
    rewrite ^/app_dev\.php/?(.*)$ /$1 permanent;

    client_max_body_size 50m;

    location / {
        index app_dev.php;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app_dev.php/$1 last;
    }

    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ ^/(app|app_dev|app_staging|config)\.php(/|$) {
        fastcgi_pass localhost:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SYMFONY__HOST__ENV "HOST_ENV";
        fastcgi_param  HTTPS off;
        fastcgi_param  QUERY_STRING     $query_string;
   }
}

HOST_ENV is usually something like production, staging, local, dev, etc.

References:

Leave a Reply

Your email address will not be published. Required fields are marked *