When I create new web applications on my up-2-date Ubuntu-LAMP with Apache 2.4.x environment, I create their virtual-host files this way:
s_a="/etc/apache2/sites-available/"s_e="/etc/apache2/sites-enabled/"read -p "Have you created db credentials already?" yncase $yn in [Yy]* ) break;; [Nn]* ) exit;; * ) echo "Please create db credentials in then comeback;";;esacread -p "Please enter the domain of your web application:" domain_1 && echoread -p "Please enter the domain of your web application again:" domain_2 && echoif [ "$domain_1" != "$domain_2" ]; then echo "Values unmatched. Please try again."&& exit 2; firead -sp "Please enter the app DB root password:" dbrootp_1 && echoread -sp "Please enter the app DB root password again:" dbrootp_2 && echoif [ "$dbrootp_1" != "$dbrootp_2" ]; then echo "Values unmatched. Please try again."&& exit 2; firead -sp "Please enter the app DB user password:" dbuserp_1 && echoread -sp "Please enter the app DB user password again:" dbuserp_2 && echoif [ "$dbuserp_1" != "$dbuserp_2" ]; then echo "Values unmatched. Please try again."&& exit 2; ficat <<-EOF > "$s_a/$domain_2.conf"<VirtualHost *:80> ServerAdmin admin@"$domain_2" ServerName ${domain_2} ServerAlias www.${domain_2} DocumentRoot /var/www/html/${domain_2} ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>EOFln -sf "$s_a"/"$domain_2".conf "$s_e"
My question
Is there a way to automate that / shorten the amount of lines code (the actual script-file is much bigger in principle), maybe even from some built-in behavior in Apache itself and without involving further software?
If other software might be needed than from what I've read so far it should be Docker and I should look for an Apache-virtual host docker script that will be based on my variable declarations (in dockerhub) which I will then run with a docker
command, but maybe Apache itself will have automation functionality for this or there is some third solution the answer's my need?