is to automate the creation of a new a VHOST (virtual host) for an Apache server based on the assumptions below. This script has been tested as working on Ubuntu 14.04, 16.04, 20.04.
- takes 1 input parameter: the
<projectname> - generates and set permissions on
/etc/apache2/sites-available/<projectname>.conf - creates
/web/webroot/<projectname>folder and sets folder permissions - adds
/etc/apache2/sites-available/<projectname>.conftoa2ensite - runs
service apache2 restartenabling the website and making it active - generates a reference to
<projectname>in/etc/hostsfor local DNS resolution ofhttp://<projectname>/
- creating a LAMP-based website (linux/apache/mysql/php)
- website rooted @
/web/webroot/<projectname> - script located @
/web/scripts/createnewsite.sh - owner
www-data - group
webdev - this file exists:
/etc/apache2/sites-available/website-tpl.conf(located below)
- apache2
- conf template file:
/etc/apache2/sites-available/website-tpl.conf
sh /web/scripts/createnewsite.sh <projectname>
The <projectname> will be used to:
- create a
<projectname>directory under/web/webroot/ - add the DNS HOSTS entry to resolve
http://<projectname>locally
This script currently has the webroot folder, and the projectowner and projectgroup permissions hardcoded.
Future plans involve removing these hardcoded values.