Created
September 30, 2013 19:46
-
-
Save omgmog/6769123 to your computer and use it in GitHub Desktop.
Bash function to create Apache site files magically.
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
function makeconf { | |
primary=${1} | |
conffile="${conf}/${primary}.conf" | |
echo "<VirtualHost *:80>" >> "${conffile}" | |
echo " Servername ${primary}" >> "${conffile}" | |
echo " ServerAlias www.${primary}" >> "${conffile}" | |
shift | |
for i; do | |
cat >> "${conffile}" <<EOL | |
ServerAlias ${i} | |
ServerAlias www.${i} | |
EOL | |
done | |
echo " DocumentRoot /srv/www/${primary}" >> "${conffile}" | |
echo "</VirtualHost>" >> "${conffile}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
makeconf maindomain [alternatedomain_1 alternatedomain_2 alternatedomain_n]
This script assume that you have a variable called
conf
that points to the location of your Apache site files (such as/etc/apache2/sites-enabled
)