Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx PHP-FPM Symfony 2 minimal config
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
# Deny all . files
location ~ /\. {
deny all;
}
location ~ ^/(app|app_dev)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index app.php;
send_timeout 1800;
fastcgi_read_timeout 1800;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
}
# Statics
location /(bundles|media) {
access_log off;
expires 30d;
# Font files
#if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
# add_header Access-Control-Allow-Origin *;
#}
try_files $uri @rewriteapp;
}
}
@NikolayGalkin

This comment has been minimized.

Copy link

@NikolayGalkin NikolayGalkin commented Jun 3, 2013

thanks a lot! =)

@tur-nr

This comment has been minimized.

Copy link

@tur-nr tur-nr commented Jul 4, 2013

why thank you kind sir.

@shinvdu

This comment has been minimized.

Copy link

@shinvdu shinvdu commented Jul 22, 2013

太感谢了,不过,提醒下:symfony2 ,
应该把
location ~ ^/(app|app_dev).php(/|$) {
改为
location ~ ^/web/(app|app_dev).php(/|$) {

@tibezh

This comment has been minimized.

Copy link

@tibezh tibezh commented Jul 29, 2013

Thank you very much!

@nass600

This comment has been minimized.

Copy link

@nass600 nass600 commented Aug 19, 2013

Nice starting point. Thank you.

@arunmdavid

This comment has been minimized.

Copy link

@arunmdavid arunmdavid commented Mar 13, 2014

Simple and clear. Thnx.

@vamsiikrishna

This comment has been minimized.

Copy link

@vamsiikrishna vamsiikrishna commented Apr 1, 2014

nice , thanks for sharing

@onema

This comment has been minimized.

Copy link

@onema onema commented Apr 3, 2014

it works! thank you.

@madmis

This comment has been minimized.

Copy link

@madmis madmis commented May 24, 2014

cool. You help me. Thank you.

@koryonik

This comment has been minimized.

Copy link

@koryonik koryonik commented Jul 25, 2014

Clear, thanks for sharing.

@paulsutcliffe

This comment has been minimized.

Copy link

@paulsutcliffe paulsutcliffe commented Aug 14, 2014

Awesome!!! Thanks

@sfarkas1988

This comment has been minimized.

Copy link

@sfarkas1988 sfarkas1988 commented Nov 11, 2014

it works fine! Thank you!

@n1c01a5

This comment has been minimized.

Copy link

@n1c01a5 n1c01a5 commented Apr 6, 2015

no works for me I have this error: "file not found"

@valetanddama

This comment has been minimized.

Copy link

@valetanddama valetanddama commented Aug 23, 2015

Because fastcgi_params file(line 21) you need to create

@PezCoder

This comment has been minimized.

Copy link

@PezCoder PezCoder commented Jan 20, 2016

This configuration needs to be put directly inside nginx.conf or inside http block in the same file?

@bclincy

This comment has been minimized.

Copy link

@bclincy bclincy commented Mar 24, 2017

Just what I needed thank you sir!

@logicoim

This comment has been minimized.

Copy link

@logicoim logicoim commented Sep 6, 2017

Thanks for sharing.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Oct 31, 2017

Thanks, you saved me.

@mkifia

This comment has been minimized.

Copy link

@mkifia mkifia commented Oct 3, 2019

great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.