Last active
August 25, 2017 06:07
-
-
Save luiseduardobraschi/3be143208556827b77df93891a0e834d to your computer and use it in GitHub Desktop.
Apache 2's a2ensite and a2dissite for non-Deb based distros. Source (slightly modified): Apache virtual hosting in CentOS http://www.tecmint.com/apache-virtual-hosting-in-centos/
This file contains hidden or 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 | |
avail=/etc/httpd/sites-enabled/$1.conf | |
enabled=/etc/httpd/sites-enabled | |
site=`ls /etc/httpd/sites-enabled/` | |
if [ "$#" != "1" ]; then | |
echo "Use script: a2dissite virtual_site" | |
echo -e "\nAvailable virtual hosts: \n$site" | |
exit 0 | |
else | |
if test -e $avail; then | |
sudo rm $avail | |
else | |
echo -e "$avail virtual host does not exist! Exiting!" | |
exit 0 | |
fi | |
if test -e $enabled/$1.conf; then | |
echo "Error! Could not remove $avail virtual host!" | |
else | |
echo -e "Success! $avail has been removed!" | |
exit 0 | |
fi | |
fi |
This file contains hidden or 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/ | |
if test -d /etc/httpd/sites-available && test -d /etc/httpd/sites-enabled ; then | |
echo "-----------------------------------------------" | |
else | |
mkdir -p /etc/httpd/sites-available | |
mkdir -p /etc/httpd/sites-enabled | |
fi | |
avail=/etc/httpd/sites-available/$1.conf | |
enabled=/etc/httpd/sites-enabled/ | |
site=`ls /etc/httpd/sites-available/` | |
if [ "$#" != "1" ]; then | |
echo "Use script: a2ensite virtual_site" | |
echo -e "\nAvailable virtual hosts:\n$site" | |
exit 0 | |
else | |
if test -e $avail; then | |
sudo ln -s $avail $enabled | |
else | |
echo -e "$avail virtual host does not exist! Please create one!\n$site" | |
exit 0 | |
fi | |
if test -e $enabled/$1.conf; then | |
echo "Site ${1} enabled successfully" | |
else | |
echo -e "Virtual host $avail does not exist!\nPlease see available virtual hosts:\n$site" | |
exit 0 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment