How do I create non-SSL name-based virtual hosts on my Apache 2 web server, Mac OS X 10.5 (client) computer?

Instructions for setting up name-based virtual hosting to identify multiple non-SSL virtual hosts (all on port 80, for example).


Here’s why you might do this:

  • You have separate test and development areas on your Web server.
  • You have more than one Web site on your Web server.
  • You simultaneously run different versions of Lasso on your Web server (for example Lasso 8.5.6 and 9).

  • Back up files BEFORE making changes!
  • I use BBEdit File->Open Hidden to open all files.
  • This is what I did on my Mac OS X 10.5 (client) powerbook. I believe it will also work for Mac OS X 10.6 thru 10.8 (client).
  • Tested on Firefox and Safari.


  1. Open /private/etc/hosts:
  2. Add a line for each virtual host to the bottom:

    (ex. url =
  3. Open /private/etc/apache2/extra/httpd-vhosts.conf and add all virtual hosts:
  4. Open /private/etc/apache2/httpd.conf and uncomment the line for virtual hosts:
  5. To check for configuration errors and if none are found, restart the Web server, type (in Terminal):
  6. Restart your computer.
  7. Check that your Web server (and Lasso, if you’re using Lasso) are working correctly. Open a web browser and go to and one of your virtual hosts, ex. and, if you’re using Lasso, one of your Lasso web sites.

What to watch out for

Don’t skip step #5! If any errors are reported when you do sudo apachectl configtest your Web server probably won’t run.

You must restart your computer in step #6 before it will see the change made in step #2 (/private/etc/hosts).

Next Step

How do I add a virtual host with self-signed SSL to my Apache 2 web server, Mac OS X 10.5 (client) computer?