Today, in order to make some testing easier, I wanted to setup a named virtual host in Apache. Here’s how I did it.
mate /etc/hosts # open hosts file in textmate
Add this line:
This tells your browser (or whatever) to look on your personal webserver for any requests to www.layersix.dev. In terminal, do
to make sure you clear your cache of dns names.
This is the apache settings file. Look for “NameVirtualHost” and make sure the line reads
Make sure there is no # before this.
Add the following:
<virtualhost *:80=""> DocumentRoot /Library/WebServer/Documents/layersix.dev ServerName www.layersix.dev </virtualhost>
Go to /Library/WebServer/Documents/ and make a folder called layersix.dev (or whatever). Make a file called index.html and put some text in it. I did echo ‘hi’ > layersix.dev/index.html. Restart your webserver in System Preferences > Sharing. Go to www.layersix.dev in Firefox or whatever browser you use. You should now see your index.html file.
This post was helpful in figuring this out: