Skip to content

Instantly share code, notes, and snippets.

@kogakure
Forked from trey/vhost.sh
Created March 4, 2009 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kogakure/73782 to your computer and use it in GitHub Desktop.
Save kogakure/73782 to your computer and use it in GitHub Desktop.
Bash: Create virtual hosts with `sudo vhost site-name` (Mac OSX Leopard). By Jason Tan.
#!/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 " ServerAdmin you@your-mac.local" >> $VHOST
echo " DocumentRoot \"$DIR\"" >> $VHOST
echo " ServerName $1.dev" >> $VHOST
echo "</VirtualHost>\n" >> $VHOST
echo "127.0.0.1 $1.dev" >> /etc/hosts
apachectl graceful
mate $DIR
open http://$1.dev/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment