Skip to content

Instantly share code, notes, and snippets.

@joshangell
Created December 20, 2012 10:15
Show Gist options
  • Save joshangell/4344416 to your computer and use it in GitHub Desktop.
Save joshangell/4344416 to your computer and use it in GitHub Desktop.
Simple script for setting up a new local site on a mac's native apache.
#!/bin/bash
echo "enter directory path, leave blank for current"
read DOCROOT
if [ -z "$DOCROOT" ];
then
DOCROOT="$PWD"
fi
echo "enter domain name, defaults to current directory and will end in .dev"
read DOMAIN
if [ -z "$DOMAIN" ];
then
DOMAIN="${PWD##*/}"
fi
echo "127.0.0.1 $DOMAIN.dev" >> /etc/hosts
FILE="/etc/apache2/extra/httpd-vhosts.conf"
echo "<VirtualHost *:80>" >> $FILE
echo " ServerName $DOMAIN.dev" >> $FILE
echo " ServerAlias $DOMAIN.*.xip.io" >> $FILE
echo " DocumentRoot $DOCROOT" >> $FILE
echo "</VirtualHost>" >> $FILE
apachectl restart
echo "All done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment