Skip to content

Instantly share code, notes, and snippets.

@simplyadrian
Last active August 29, 2015 14:21
Show Gist options
  • Save simplyadrian/4418bcb1671fbe32dd8e to your computer and use it in GitHub Desktop.
Save simplyadrian/4418bcb1671fbe32dd8e to your computer and use it in GitHub Desktop.
bash script to create vhosts in apache
#!/bin/bash -e
#
#
# Test for a reboot, if this is a reboot just skip this script.
#
if test "$RS_REBOOT" = "true" -o "$RS_ALREADY_RUN" = "true" ; then
logger -t RightScale "WEB Apache ocs vhost, skipped on a reboot."
exit 0
fi
if [ $RS_DISTRO = ubuntu ]; then
APACHE="apache2"
elif [ $RS_DISTRO = centos ]; then
APACHE="httpd"
fi
# Add vhosts
cp $VHOST_CONFIG/$ENV/* /etc/${APACHE}/sites-available
# Reload apache with the new vhosts
for vhost in $(ls /etc/${APACHE}/sites-available | grep conf$); do
a2ensite ${vhost}
done
# Disable the default apache vhost
for vhost in $(ls /etc/${APACHE}/sites-available | grep default.conf); do
a2dissite ${vhost}
done
a2enmod rewrite enable
service ${APACHE} restart
logger -t RightScale "HTTP Vhost configuration done."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment