Skip to content

Instantly share code, notes, and snippets.

@elioair
Last active October 4, 2015 00:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Script to create a website in apache in a LAMP stack.
#!/bin/bash
# permissions
if [ "$(whoami)" != "root" ]; then
echo "Not enough privileges. Run this with sudo."
exit
fi
echo Please, enter website domain [of the form domainname.dev]
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 '127.0.0.1 %s\n' $NAME >> /etc/hosts
echo "Restarting Apache"
service apache2 restart
echo "Complete!"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment