Created
October 14, 2013 06:57
-
-
Save Jan-Bart/6971819 to your computer and use it in GitHub Desktop.
Create a new local site (on mac os 10.8.5 without MAMP)
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 | |
# settings | |
VHOSTSFILE="/private/etc/apache2/extra/httpd-vhosts.conf" | |
SITEPATH="/Users/USERNAME/Sites/" | |
# run this as root | |
read -p "New local site name: " SITE | |
#/etc/hosts | |
cp /etc/hosts /etc/hosts.original | |
echo -e "\n127.0.0.1\t${SITE}" >> /etc/hosts | |
# create a folder in de sites map | |
mkdir -p ${SITEPATH}${SITE}; | |
# create template | |
cd ${SITEPATH}${SITE} | |
echo "<html><body><h1>Placeholder for ${SITE}</h1></body></html>" > index.html | |
# httpd-vhosts.conf | |
cp $VHOSTSFILE ${VHOSTSFILE}.original | |
printf "\n<VirtualHost *:80>" >> $VHOSTSFILE | |
echo -e "\n\tDocumentRoot \"${SITEPATH}${SITE}\"" >> $VHOSTSFILE | |
echo -e "\tServerName ${SITE}" >> $VHOSTSFILE | |
echo -e "\tServerAlias www.${SITE}" >> $VHOSTSFILE | |
echo -e "\tErrorLog \"/private/var/log/apache2/${SITE}-error_log\"" >> $VHOSTSFILE | |
echo -e "\tCustomLog \"/private/var/log/apache2/${SITE}-access_log\" common" >> $VHOSTSFILE | |
echo -e "\t<Directory ${SITEPATH}${SITE}>" >> $VHOSTSFILE | |
echo -e "\t\tOptions -Indexes IncludesNOEXEC FollowSymLinks" >> $VHOSTSFILE | |
echo -e "\t\tallow from all" >> $VHOSTSFILE | |
echo -e "\t\tAllowOverride All" >> $VHOSTSFILE | |
echo -e "\t</Directory>" >> $VHOSTSFILE | |
echo '</VirtualHost>' >> $VHOSTSFILE | |
#restart apache | |
sudo apachectl restart | |
# change permissions on folder | |
chmod a+rx ${SITEPATH}${SITE} | |
echo -e "We're done. Goodbye." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment