- Simple maps for vhost locations and PHP versions
- Still allows custom vhosts when added manually inside
conf.d/
WARNING: I use this setup for local development, it is not meant to be used in production as is.
# conf.d/default.conf | |
server { | |
listen 80; | |
listen [::]:80 ipv6only=on; | |
server_name ~.; | |
include php_host.conf; | |
} |
user www-data www-data; | |
pid /var/run/nginx.pid; | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
ssl_protocols TLSv1.2 TLSv1.1 TLSv1; | |
include php_map.conf; | |
include conf.d/*.conf; | |
} |
charset utf-8; | |
index index.php index.html index.htm; | |
root $vhost_root; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
fastcgi_buffers 16 16k; | |
fastcgi_buffer_size 32k; | |
fastcgi_pass $php_backend; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; | |
include fastcgi_params; | |
} |
upstream php71 { | |
server unix:/run/php/php7.1-fpm.sock; | |
} | |
upstream php72 { | |
server unix:/run/php/php7.2-fpm.sock; | |
} | |
map $http_host $php_backend { | |
hostnames; | |
*.appl "php72"; | |
*.deve "php71"; | |
default "php72"; | |
} | |
map $http_host $vhost_root { | |
hostnames; | |
*.deve /var/www/$http_host/public_html; | |
*.appl /var/www/$http_host/public; | |
default /var/www/$http_host; | |
} |