Make and Unmake Sites, Automated

Managing another website brings in some issues, like the setup.  Surely this can be automated! I’ve had the site maker script working for a few months, but I just got the site unmaker script working, and I thought I would share those here.

I’m using Ubuntu Server 16.04 LTS with Apache2 and Certbot.  I’ve automated the setup of the virtual host config file for each subdomain, the acquisition of the SSL certificate from Certbot, and creating a landing page for the site.  My site root is in /var/www/ with the domain following that.  The subdomain is in the next level down using its FQDN.  The folder to this blog is /var/www/lupecode.com/blog.lupecode.com/ following that schema.

I have make-site.sh and unmake-site.sh.

Here is make-site:

First we collect some settings from the user setting up the site.

The next step is to create the site folder

The landing page and the configuration file are created next.

The site is enabled in Apache2, and then Certbot is called.

The CertBot call use to be better, but the Apache plugin was disabled as there is a security vulnerability in it.

CertBot restarts Apache2 for us, so our new site is online.


To unmake the site is much easier.

The first thing that is done is similar, the script needs the FQDN and the folder that it is in.

Apache2 is called to disable the HTTP and HTTPS site, and we delete the configuration file.  The deletion of the SSL certificates is done by Certbot.  The script removes the folder to the site, and lastly reloads Apache2’s configurations.


This is what is looks like to run the make-site script.  I’ve highlighted the input lines.

So check it out: https://make-site.lupecode.com/

The repository for this post can be found on GitLab here .

The repository for this post can be found on Lupe Code’s GitLab mirror here .