Created
July 21, 2020 07:48
-
-
Save haljeshi/bbc117688e5cf9cf70780eeba70df438 to your computer and use it in GitHub Desktop.
usage `sudo makewebsite mynewwebsite` and then you will be able to navigate to mynewwebsite.test. To work, it will need the template vhost to be in place (https://gist.github.com/haljeshi/b1247624518a2f23b4a75820bb20c4d0)
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/sh | |
WEBSITE="$1" | |
Green='\033[0;32m' | |
Color_Off='\033[0m' | |
echo -e $Green | |
echo "Creating $WEBSITE.test.conf..." | |
cp /etc/apache2/sites-available/template /etc/apache2/sites-available/$WEBSITE.test.conf | |
echo "Processing $WEBSITE.test.conf..." | |
sed -i "s/WEBSITEVAR/$WEBSITE/g" /etc/apache2/sites-available/$WEBSITE.test.conf | |
echo "Enabling $WEBSITE.test.conf..." | |
a2ensite $WEBSITE.test.conf | |
echo "Restarting Apache2..." | |
service apache2 restart | |
echo "Creating /var/www/$WEBSITE..." | |
mkdir /var/www/$WEBSITE | |
echo "Creating test file..." | |
cat > /var/www/$WEBSITE/index.php << EOF | |
<?php echo "Hello World from $WEBSITE"; ?> | |
EOF | |
echo "Adding $WEBSITE.test to hosts..." | |
echo "127.0.0.1 $WEBSITE.test" >> /etc/hosts | |
echo "Fixing permission for /var/www/$WEBSITE" | |
fixperm /var/www/$WEBSITE | |
echo "Done!" | |
echo $Color_Off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment