Skip to content

Instantly share code, notes, and snippets.

@danpecher
Created February 10, 2017 23:45
Show Gist options
  • Save danpecher/232e583baa36787afa74958a6ead6f69 to your computer and use it in GitHub Desktop.
Save danpecher/232e583baa36787afa74958a6ead6f69 to your computer and use it in GitHub Desktop.
server {
listen 8080;
server_name app localhost .dev;
set $basepath /Users/dan/Code;
set $domain $host;
if ($domain ~ "^(.*)\.dev$") {
set $domain $1;
}
set $rootpath "${domain}";
# symfony
if (-d $basepath/$domain/web) {
set $rootpath "${domain}/web";
}
if (-f $basepath/$domain/index.html) {
set $rootpath $domain;
}
if (-f $basepath/$domain/index.php) {
set $rootpath $domain;
}
# most frameworks
if (-d $basepath/$domain/public) {
set $rootpath "${domain}/public";
}
# nette
if (-d $basepath/$domain/www) {
set $rootpath "${domain}/www";
}
# cakephp
if (-d $basepath/$domain/webroot) {
set $rootpath "${domain}/webroot";
}
location ~* \.(css|js|ico)$ {
try_files $uri =404;
}
index index.php index.html;
location / {
if (-f $request_filename) {
break;
}
try_files $uri $uri/ /index.php?$args;
}
root $basepath/$rootpath;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ ^/(app|app_dev)\.php {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index app_dev.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /usr/local/etc/nginx/fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment