Nginx-WordPress conf
You are putting your server_name to be $domain and www.$domain. What if, someone puts in www.example.com for the script argument? You will thne be serving www.example.com and www.www.example.com. Instead; replace possible www. from the domain variable.

domain="${domain#www\.}"


Each of your location section has a different indentation. Keep it consistent. Since server section is the root level, you do not need to indent it out. I understand that you are flushing the left indentation from the conf, but I would suggest keeping it, since one might want to peek at them in future, and would like to tweak it?



#!/bin/bash
domain="$1" &amp;&amp; test -z "$domain" &amp;&amp; exit 2
domain="${domain#www\.}"
drt="/var/www/html" 

cat &lt;&lt;EOF &gt; "$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&amp;$args;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }
    location ~* \.(jpe?g|png|gif|ico|css|js|ttf|woff|pdf)$ {
        expires 365d;
    }
}

EOF