Last active
December 10, 2015 01:19
-
-
Save slywalker/4357786 to your computer and use it in GitHub Desktop.
nginx dynamic root vhost conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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