Skip to content

Instantly share code, notes, and snippets.

@jasonmelgoza
Forked from trey/treyvhost
Created April 6, 2010 01:11
Show Gist options
  • Save jasonmelgoza/357082 to your computer and use it in GitHub Desktop.
Save jasonmelgoza/357082 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Original script by Jason Tan: http://solutions.treypiepmeier.com/2009/03/03/virtual-hosts-on-osx-leopard/#comment-41787
DIR=/Users/$SUDO_USER/Sites/$1
if [[ ! -d $DIR && `id -u` -eq 0 ]]; then
echo ""
echo "Downloading site-template repository ..."
sudo -u $SUDO_USER git clone --quiet git://github.com/trey/site-template.git $DIR
cd $DIR
echo "Deleting unneeded parts ..."
rm -rf .git/
rm .gitignore
mv html5.html index.html
rm html4.html
rm html4_lean.html
rm xhtml.html
rm xhtml_full.html
rm README.markdown
rm MIT-License.txt
mate $DIR
open http://127.0.0.1:8080/
python -m SimpleHTTPServer 8080
echo ""
echo "Done!"
else
echo "usage: sudo pyhost YOUR_PROJECT"
fi
#!/bin/sh
# Original script by Jason Tan: http://solutions.treypiepmeier.com/2009/03/03/virtual-hosts-on-osx-leopard/#comment-41787
DIR=/Users/$SUDO_USER/Sites/$1
if [[ ! -d $DIR && `id -u` -eq 0 ]]; then
echo ""
echo "Downloading site-template repository ..."
sudo -u $SUDO_USER git clone --quiet git://github.com/trey/site-template.git $DIR
cd $DIR
echo "Deleting unneeded parts ..."
rm -rf .git/
rm .gitignore
mv html5.html index.html
rm html4.html
rm html4_lean.html
rm xhtml.html
rm xhtml_full.html
rm README.markdown
rm MIT-License.txt
VHOST=/etc/apache2/users/$SUDO_USER.conf
echo "<VirtualHost *:80>" >> $VHOST
echo "\tDocumentRoot \"$DIR\"" >> $VHOST
echo "\tServerName $1.dev" >> $VHOST
echo "</VirtualHost>\n" >> $VHOST
echo "VirtualHost created in $VHOST ..."
echo "127.0.0.1\t$1.dev" >> /etc/hosts
echo "/etc/host updated ..."
apachectl restart
mate $DIR
open http://$1.dev
echo ""
echo "Done!"
else
echo "usage: sudo treyvhost directory"
fi
@jasonmelgoza
Copy link
Author

Thinking of replacing the v-host with pythons simple server

cd the dir then:
python -m SimpleHTTPServer 8080

Running the vhost stuff seem to break my local apache setup. At least for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment