Skip to content

Instantly share code, notes, and snippets.

@slywalker
Last active December 10, 2015 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slywalker/4357786 to your computer and use it in GitHub Desktop.
Save slywalker/4357786 to your computer and use it in GitHub Desktop.
nginx dynamic root vhost conf
server {
listen 80;
server_name ~^(.*)\.local\.dev$;
set $_document_root /opt/local/var/www/$1;
set $_server_name $1.local.dev;
# if directory doesn't exist
if (!-e $_document_root) {
rewrite ^ http://localhost last;
}
# Sets the correct root
root $_document_root;
index index.php index.html index.htm;
access_log off;
try_files $uri $uri/ /index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
fastcgi_param SERVER_NAME $_server_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment