Last active
October 4, 2015 00:34
-
-
Save elioair/f3b58a7c9ec1a9df38f0 to your computer and use it in GitHub Desktop.
Script to create a website in apache in a LAMP stack.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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