Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Trying to setup apache virtual host on my macbook pro for development.

Want to setup site so i can use the following url format.


This resolves to apache's default index.html.en, the one which say's "It works!"

However, when I use http://localhost/example, seems to load example's index file.

Any ideas?

This is my setup

copy of my /etc/hosts file       localhost       example.local broadcasthost
#::1            localhost
#fe60::1%lo0    localhost

copy of /etc/apache2/extra/httpd-vhosts.conf file

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName example.local
  ServerAlias example.local
  DocumentRoot /Library/WebServer/Documents/example
  #DirectoryIndex index.php
  <Directory /Library/WebServer/Documents/example/>
    Order Allow,Deny
    Allow from All
    Options Indexes FollowSymLinks

I have remove other vhost from the file to eliminate vhost clashing.

Thanks Dinesh.

share|improve this question

migrated from Dec 18 '11 at 8:56

This question came from our site for professional and enthusiast programmers.

up vote 0 down vote accepted

Have you uncommented the following line in your httpd.conf and restarted apache?

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

This, as it looks includes the vhosts conf httpd-vhosts.conf.

share|improve this answer
Thanks. You were right, I needed to uncomment the line out in httpd.conf to include the vhost.conf. Should have realised. Thinking about it, the reason why localhost/example was resolvin, is that the example web app folder is in the Document Root of the main httpd.conf. i.e. In httpd.conf DocumentRoot "/Library/WebServer/Documents" From my understanding, when the user types - localhost/example apache will serve files from /Library/WebServer/Documents/example/ Thanks again. – Dinesh Dec 18 '11 at 20:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.