This is how I create am Nginx virtual host for a WordPress webapp. I did best to keep it as minimal as I can while having a working webapp. Please review it:
#!/bin/bash
domain="$1" && test -z "$domain" && exit 2
drt="/var/www/html"
cat <<-EOF > "$s_a/$domain.conf"
server {
root ${drt}/${domain};
server_name ${domain} www.${domain};
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
expires 365d;
}
}
EOF