Nginx Symfony2 Server Configuration

Published on Author craigzearfossLeave a comment
server {
    listen 80;
    #listen [::]:80 default_server ipv6only=on;root /usr/share/nginx/html;
    #index index.php index.html index.htm;

    server_name DOMAIN_NAME;
    root /var/www/SITE_DIRECTORY/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;
        # include php5-fpm.conf;
        fastcgi_param  HTTPS off;
	fastcgi_param  QUERY_STRING $query_string;

Leave a Reply

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