0

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?

  • Questions about how a server environment should be setup belong on ServerFault.com. – Erik Philips Sep 13 '11 at 03: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. – user9517 Sep 14 '11 at 08:16

2 Answers2

1

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

Cody
  • 163
  • 3
1

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!