-
-
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.
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/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