Last Updated: February 25, 2016
·
789
· kayue

Nginx Symfony 2 Config

Important Remark: The following configuration makes all PHP scripts except app.php, app_dev.php and config.php downloadable instead of executing them. This is probably not desired if you'd like to use a tool like phpMyAdmin in the same virtual host.

server {
    # make sure you point it at the "web" subfolder
    root /PATH/TO/PROJECT/web; 
    server_name SERVER_NAME;

    index app.php;
    try_files $uri $uri/ /app.php?$query_string;

    location ~ ^/(app_dev|app|config.php)\.php(/|$) {
        include fastcgi_params;
        # you may change the following parameter
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}