Skip to content

Instantly share code, notes, and snippets.

@haswalt
Created March 5, 2011 13:01
Show Gist options
  • Save haswalt/856337 to your computer and use it in GitHub Desktop.
Save haswalt/856337 to your computer and use it in GitHub Desktop.
ngxin config for working with php-fpm and symfony using wildcard vhosts. "sfdev" is the suffix for hosts so to get to the site for example you would use http://example.sfdev/
server {
server_name .sfdev;
index index.php;
autoindex on;
client_max_body_size 256M;
charset utf-8;
set $root "";
if ($host ~* ^(admin\.)?(.+)\.sfdev) {
set $root $2;
set $admin $1;
}
location / {
root /Users/harry/Sites/symfony/$root/web;
if (-f $request_filename) {
break;
}
set $filename "index.php";
if ($admin = admin.) {
set $filename "backend_dev.php";
}
if ($request_filename !~ "\.(htc|ico|gif|jpg|png|css)$") {
rewrite ^(.*) /$filename 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 SCRIPT_FILENAME /Users/harry/Sites/symfony/$root/web$script;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_NAME $script;
}
location /sf/ {
root /usr/share/php/data/symfony/web;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment