Skip to content

Instantly share code, notes, and snippets.

Last active October 4, 2015 00:34
What would you like to do?
Script to create a website in apache in a LAMP stack.
# permissions
if [ "$(whoami)" != "root" ]; then
echo "Not enough privileges. Run this with sudo."
echo Please, enter website domain [of the form]
read NAME
echo "Creating the configuration file"
echo "<VirtualHost *:80>
DocumentRoot /var/www/html/$NAME
ServerName $NAME
ServerAlias www.$NAME
</VirtualHost>" >> /etc/apache2/sites-available/$NAME.conf
echo "Enabling the site"
a2ensite $NAME
echo "Adding site to hosts file"
printf ' %s\n' $NAME >> /etc/hosts
echo "Restarting Apache"
service apache2 restart
echo "Complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment