The following script is aimed for Ubuntu >=16.04
LEMP environments with PHP-FPM >=7.0
, MySQL, WP-CLI, Certbot, and WordPress apps.
The script get’s one domain as an argument and creates the following aspects based on that argument (wp=WordPress, nx=Nginx, drt=document-root
):
- wp app directory in drt.
- wp installation in drt/domain.
- wp_conf in drt/domain.
- nx_app conf in /etc/nginx/sites-available/
- nx_symlink in /etc/nginx/sites-enabled/
- nx_certbot configuration.
$ {drt}
= document root.
One could then add a database stack via MySQL, accordingly (and also edit the website files, accordingly).
#!/bin/bash domain="$ 1" && test -z $ {domain} && return read -sp "DB user password:" dbuserp mkdir $ {drt}/$ {domain}/ wp core download --path=$ {drt}/$ {domain}/ --allow-root wp config create --path=$ {drt}/$ {domain}/ --dbname=$ {domain} --dbuser=$ {domain} --dbpass=$ {dbuserp} --dbhost="localhost" --allow-root sed "s/$ {domain}/$ {1}/g" ~/nginx_app > /etc/nginx/siteas-available/$ {domain}.conf ln -sf /etc/nginx/sites-available/$ {domain}.conf /etc/nginx/sites-enabled/ certbot --nginx -d $ {domain} -d www.$ {domain} echo "Please configure DBstack in phpmyadmin." echo "Please change permissions as you prefer and restart the Nginx server."
Clarification
The conf template I redirect from ~/nginx_app
, for the Nginx app conf, is this one:
server { root $ {drt}/$ {domain}/; server_name $ {domain} www.$ {domain}; location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ { expires 365d; } }
Please share your opinion on the above script and adjacent conf file.