Skip to content

Instantly share code, notes, and snippets.

@zhangyoufu
Last active April 14, 2016 02:31
Show Gist options
  • Select an option

  • Save zhangyoufu/2fe617beccf95d8854490de0050713bd to your computer and use it in GitHub Desktop.

Select an option

Save zhangyoufu/2fe617beccf95d8854490de0050713bd to your computer and use it in GitHub Desktop.
bring lighttpd mod_simple_vhost to nginx
# for test purpose only, do not use in production
# inspired by http://blog.pkh.me/p/4-simple_vhost-with-nginx.html
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name default;
server_name_in_redirect off;
set $vpath /srv/_vhost/$host;
if ( !-d $vpath ) {
set $vpath /srv/default;
}
root $vpath;
error_page 403 =404 /;
location / {
index index.php index.html;
}
location ^~ /_public {
autoindex on;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
include fastcgi.conf;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment