Skip to content

Instantly share code, notes, and snippets.

@gnarargs
Created December 22, 2009 11:05
Show Gist options
  • Save gnarargs/261673 to your computer and use it in GitHub Desktop.
Save gnarargs/261673 to your computer and use it in GitHub Desktop.
#!/bin/bash
# sudo vhost dir domain
# $1 is the name of the directory in sites
# $2 is the domain to add to hosts file
# create a new site
if [ -d $HOME/Sites/$1 ]
then
echo "Site directory already exists, exiting"
exit 1
else
mkdir $HOME/Sites/$1
fi
# update hosts
echo -e "\n127.0.0.1 $2.dev" >> /etc/hosts
# update virtual hosts
echo -e "\n<VirtualHost *:80>\n\t DocumentRoot \"$HOME/Sites/$1\"\n\tServerName $2.dev\n\t</VirtualHost>" >> /etc/apache2/extra/httpd-vhosts.conf
# restart apache
apachectl restart
echo "Site successfully created"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment