Skip to content

Instantly share code, notes, and snippets.

@jcartledge
Created February 6, 2011 03:45
Show Gist options
  • Save jcartledge/813108 to your computer and use it in GitHub Desktop.
Save jcartledge/813108 to your computer and use it in GitHub Desktop.
UBUNTU: Quickly set up a named vhost to serve the directory you are in
#!/bin/bash
sudo sh -c "echo \"127.0.0.1 $1\" >> /etc/hosts"
DIR=`pwd`
sudo sh -c "echo \"<VirtualHost *:80>
ServerName $1
DocumentRoot $DIR
</VirtualHost>\" > /etc/apache2/sites-available/$1"
sudo a2ensite $1
sudo /etc/init.d/apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment