Name based virtual hosts
I’ve revised a previous tip here with regard to setting up your mac to server virtual hosts to use your mac for development of sites. I find this to be a little easier than using 127.0.0.1 as your virtual host. Instead find the virtual host portion (usually at the bottom) of your httpd.conf file which you can find at /etc/httpd/httpd.conf. You’ll notice I’ve also added a localhost so I can continue to use localhost as a url.
Change “#NameVirtualHost *:80â€
to “NameVirtualHost *â€
To create a VirtualHost do like so:
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /Library/Webserver/Websites/bradrice
ServerName www.bradrice.dev
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /Library/WebServer/Documents
ServerName localhost
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
Now to serve up the file you will have to have a DNS entry to point to it. Use NetInfo Manager in your utilities folder. Authenticate by clicking on the lock icon. Then duplicate localhost under machines. Then enter the url you will use to server that site: www.bradrice.dev. You can add as many urls as you like. I’ve saved my directory outside the webserver root directory. You can do this, save your site wherever you like and map it using your virtualhost block.
This tip supersedes or augments the previous tip below. You can read that post at http://www.bradrice.com/wposx/?p=58