Skip to content

Instantly share code, notes, and snippets.

@sohooo
Forked from trey/vhost.sh
Created March 18, 2009 20:17
Show Gist options
  • Save sohooo/81371 to your computer and use it in GitHub Desktop.
Save sohooo/81371 to your computer and use it in GitHub Desktop.
vhosts script
#!/bin/sh
ME=your-username
DIR=/Users/$ME/Sites/$1
if [ ! -d $DIR ]
then
sudo -u $ME mkdir $DIR
sudo -u $ME touch $DIR/index.php
echo "<h1>$1</h1>" >> $DIR/index.php
fi
VHOST=/etc/apache2/extra/httpd-vhosts.conf
echo "\n<VirtualHost *:80>" >> $VHOST
echo "\tDocumentRoot \"$DIR\"" >> $VHOST
echo "\tServerName $1.dev" >> $VHOST
echo "</VirtualHost>\n" >> $VHOST
echo "127.0.0.1\t$1.dev" >> /etc/hosts
apachectl graceful
mate $DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment