Last active
June 7, 2021 09:55
-
-
Save frankiejarrett/c5c17e9b93190313b200 to your computer and use it in GitHub Desktop.
Remove a virtual host from Apache
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 | |
echo "Enter the domain of the site you want to remove:" | |
read DOMAIN | |
if [ ! -d /var/www/$DOMAIN ]; then | |
echo -e "\x1b[1;31mError:\e[0m $DOMAIN does not exist!" | |
exit 1 | |
fi | |
sudo a2dissite -q $DOMAIN.conf | |
echo "Removing hosts..." | |
sudo grep -v "$DOMAIN" /etc/hosts > /tmp/hosts ; sudo mv /tmp/hosts /etc/hosts | |
echo "Removing config..." | |
sudo rm /etc/apache2/sites-available/$DOMAIN.conf | |
echo "Removing directories..." | |
sudo rm -R /var/www/$DOMAIN | |
echo "Reloading Apache..." | |
sudo service apache2 force-reload | |
echo -e "\x1b[1;32mSuccess:\e[0m $DOMAIN removed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment