Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

127.0.0.1 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 stackoverflow.com 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 professional 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 ServerFault.com. –  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
add comment

2 Answers

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 http://tomafro.net/2009/07/dscl-the-easy-way-to-add-hosts-on-osx

share|improve this answer
add comment

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 
</Directory>

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
add comment