Automate adding a new website to Apache 2?

I am using lubuntu 20.04 with Apache 2

I was wanting to automate the creation of a new virtual host in Apache.

Can I write a script file that will do all of the MANY steps to add a new domain to Apachie 2? I would just edit the script file and put in the new virtual host name like “”. The script would add the directory and assign the appropriate rights. I would add a generic Index.htm file to the new directory.

Then when Apache on my Lubuntu machine sees a port 80 request for it would respond with the Index.htm file in directory. I think apache like to see a directory like /var/www/html/

HOWEVER this may not be possible since I think there are MANY steps plus I have to add lines to multiple files to add a new virtual host. :-((

A sever on a GUI? Why? Why?

Ok, well, people do what they want to do.

Sure, you can create a script. A script can do any number of things, so the many steps involved is irrelevant.

There’s tons of documentation out there on writing scripts, nearly all of which is universally applicable across a wide variety of Linux distributions, so I’ll leave it to you and web searches to find them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.