After a few hours, to find this (sf2 doc does not explain how the cgi parameters are needed and interpreted, you need to go through Request.php to understand), so I share this.
This is a config that looks normal with sf2 in the {subdir} directory (and web access to files other than {subdir} / web / * is prohibited).
It works for me with php-fpm (socket).
Of course, replace "{subdir}" with your / path / from / docroot / to / symfony _root /
You can select dev environmentnement by adding "dev" to "{subdir" "(since app_dev.php in the URL no longer works with this conf)
server {
Hope this helps (and there is no wrong configuration) without warranty ...
Of course, you can choose prod / dev conf if you don't need it. And instead, you can use var and only one place @ sf2:
set $sf2_root /{subdir}; location ~ ^/{subdir}(/.*)$ { set $sf2_prefix /{subdir}; set $sf2_ctrl app.php; try_files $sf2_root/web$1 @sf2; } location ~ ^/{subdir}dev(/.*)$ { set $sf2_prefix /{subdir}dev; set $sf2_ctrl app_dev.php; expires off; try_files $sf2_root/web$1 @sf2; } location @sf2 { expires off; fastcgi_pass {your backend}; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$sf2_root/web/$sf2_ctrl; fastcgi_param SCRIPT_NAME $sf2_prefix/$sf2_ctrl; fastcgi_param REQUEST_URI $sf2_prefix$1; }
source share