Server Fault is a question and answer site for system and network administrators. 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

I have spent the better part of an hour and a half trying to figure out how to get virtual hosting working under Lion's native Apache server. On my laptop, running 10.6, I was able to get virtual hosting by uncommenting this line in httpd.conf:

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

and then adding the appropriate block in the httpd-vhosts.conf file, along with adding an entry in /etc/hosts like so: foobar.local

This does not work with 10.7 for some reason. When going to http://localhost/ everything works fine, but when I try to hit foobar.local it just keeps spinning away and never loads anything. Running httpd -S from the command line shows the correct vhost configuration but that doesn't seem to matter.

The approach in this article on setting up a native MAMP stack didn't work for me either. And despite the report by some that the problem is because of IfDefine WEBSHARING_ON, for me it didn't matter where I put the Include directive.

Has anyone else had this problem? And perhaps more importantly, has anyone found a resolution?

share|improve this question

migrated from Sep 13 '11 at 7:30

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

closed as off topic by MDMarra, Mark Henderson Dec 14 '11 at 1:14

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Questions about how a server environment should be setup belong on – Erik Philips Sep 13 '11 at 3:26
@ErikPhilips: A service on a laptop is a development thing, not a system administrator thing. – freiheit Sep 13 '11 at 17:14
I would disagree, configuring IIS, Apache or any other Web Server software is an administrative task better answered on ServerVault and is definitely not a Programming Question suited for StackOverflow. – Erik Philips Sep 13 '11 at 17:23
@ErikPhilips: This will just get closed as off topic on serverfault due to it being a developer using a laptop. – Iain Sep 14 '11 at 8:16

From what I've found searching on the same topic, the ".local" TLD is reserved for Bonjour, and it won't resolve now.

Try dscl

share|improve this answer

Just throw the following line somewhere in one of the config files. Doesn't seem to matter where, as long as it runs:

<Directory "/Users/jakelodwick/sites">
    Allow from all 

The trick is replacing my name with your name. If you can do that, you'll be serving Web Site pages in no time!

share|improve this answer