This code is not fully ready for production, at the moment only application templates are of interest. Run the script at your own risk. Read the source code carefully and adapt it to your application.
This basic script:
$username.conf
in sites-available
from templates with {{username}}
and {{hostname}}
and other placeholders;sites-enabled
symlinks;Templates folder incuded apache and nginx templates for yii1, yii2 php frameworks, LMS Moodle, you free change it as you like.
/u1/www
for host files locations):
apache22
to apache24
(Issue #6);{{username}}
and {{hostname}}
placeholders for username and hostname or change template names in souce code. (TODO: ISSUES #3, #4). Also you may use some values from properties file.for Apache 2.2:
mkdir /usr/local/etc/apache22/extra/sites-available;
mkdir /usr/local/etc/apache22/extra/sites-enabled;
echo 'Include etc/apache22/extra/sites-enabled/*.conf' >> /usr/local/etc/apache22/extra/httpd-vhosts.conf;
for Apache 2.4:
mkdir /usr/local/etc/apache24/extra/sites-available;
mkdir /usr/local/etc/apache24/extra/sites-enabled;
echo 'Include etc/apache24/extra/sites-enabled/*.conf' >> /usr/local/etc/apache24/extra/httpd-vhosts.conf;
# for adding host
sh vhost.sh
# for deleteting host (removes user and disable config files)
sh rmhost.sh
# for deleteting with file removal
sh rmhost.sh -f
or (after adding symlink to /usr/sbin)
# for adding host
vhost
# for deleteting host (removes user and disable config files)
rmhost
# for deleteting with file removal
rmhost -f