Skip to content

Instantly share code, notes, and snippets.

@KevinGimbel
Created February 17, 2014 20:14
Show Gist options
  • Save KevinGimbel/9058203 to your computer and use it in GitHub Desktop.
Save KevinGimbel/9058203 to your computer and use it in GitHub Desktop.
Basics of setting up a VirtualHost with Apache (locally)
# /etc/hosts
127.0.0.1 localhost
127.8.8.8 fuckyouverymu.ch
127.0.0.8 atariba.se
127.0.0.3 typo3.local
127.0.0.5 my-awesome-site.local
# In my browser I can now use http://fuckyouverymu.ch to see my localhost (because I have no site.conf for fuckyouverymu.ch at the moment :D)
# A IP + Port, I used 127.0.0.5 to seperate if from the "normal" localhost
<VirtualHost 127.0.0.5:80>
ServerName my-awesome-site.local # the site's URL
ServerAdmin webmaster@localhost # can be anything
DocumentRoot /var/www/my-awesome-site # the site's root folder
</VirtualHost>
# That's it, the minimal config. I think it'd be possible to leave the ServerAdmin part away.
# There is a lot of more stuff that can be configured.
# A sample file can be copied from "000-default.conf" in /etc/apache2/sites-available (Linux)
# Mac OS dir should be /private/etc/apache2/other/
# Next you just need to set up the host in your hosts etc so that the URL points to the virtual host.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment