Skip to content

Instantly share code, notes, and snippets.

@brandonsimpson
Last active August 29, 2015 14:21
Show Gist options
  • Save brandonsimpson/1727f6f71ace4936ac1b to your computer and use it in GitHub Desktop.
Save brandonsimpson/1727f6f71ace4936ac1b to your computer and use it in GitHub Desktop.
Nginx php5-fpm Symfony2 app server config
server {
listen 80;
server_name symfony.dev;
root /var/www/vhosts/symfony.dev/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|config)\.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;
}
}
server {
listen 80;
server_name symfony.dev;
root /var/www/vhosts/symfony.dev/web;
index app_dev.php;
access_log /var/log/nginx/symfony.dev.access_log;
error_log /var/log/nginx/error_log;
location / {
if (-f $request_filename) {
expires max;
break;
}
if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
rewrite ^(.*) /app_dev.php last;
}
}
location ~ \.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment