Created
March 9, 2015 19:37
-
-
Save mmstick/ba38bb0f50c843eaa58c to your computer and use it in GitHub Desktop.
An Apache2 script for enabling websites.
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/conf/sites-available && test -d /etc/httpd/conf/sites-enabled ; then | |
echo "-------------------------------" | |
else | |
mkdir /etc/httpd/conf/sites-available | |
mkdir /etc/httpd/conf/sites-enabled | |
fi | |
avail=/etc/httpd/conf/sites-available/$1.conf | |
enabled=/etc/httpd/conf/sites-enabled | |
site=`ls /etc/httpd/conf/sites-available/` | |
if [ "$#" != "1" ]; then | |
echo "Use script: n2ensite 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 "Success!! Now restart Apache server: sudo systemctl restart httpd" | |
else | |
echo -e "Virtual host $avail does not exist!\nPlease see avail 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