Skip to content

Instantly share code, notes, and snippets.

@leon
Created June 29, 2012 16:34
Show Gist options
  • Save leon/3019026 to your computer and use it in GitHub Desktop.
Save leon/3019026 to your computer and use it in GitHub Desktop.
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
Copy link

thanks a lot! =)

@tur-nr
Copy link

tur-nr commented Jul 4, 2013

why thank you kind sir.

@shinvdu
Copy link

shinvdu commented Jul 22, 2013

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

@tibezh
Copy link

tibezh commented Jul 29, 2013

Thank you very much!

@nass600
Copy link

nass600 commented Aug 19, 2013

Nice starting point. Thank you.

@arunmdavid
Copy link

Simple and clear. Thnx.

@vamsiikrishna
Copy link

nice , thanks for sharing

@onema
Copy link

onema commented Apr 3, 2014

it works! thank you.

@madmis
Copy link

madmis commented May 24, 2014

cool. You help me. Thank you.

@koryonik
Copy link

Clear, thanks for sharing.

@paulsutcliffe
Copy link

Awesome!!! Thanks

@sfarkas1988
Copy link

it works fine! Thank you!

@n1c01a5
Copy link

n1c01a5 commented Apr 6, 2015

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

@valetanddama
Copy link

Because fastcgi_params file(line 21) you need to create

@PezCoder
Copy link

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

@bclincy
Copy link

bclincy commented Mar 24, 2017

Just what I needed thank you sir!

@logicoim
Copy link

logicoim commented Sep 6, 2017

Thanks for sharing.

Copy link

ghost commented Oct 31, 2017

Thanks, you saved me.

@mkifia
Copy link

mkifia commented Oct 3, 2019

great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment