Take the 2-minute tour ×

I've finally made the switch to Lion but I'm having trouble setting up an Apache VirtualHost. This is what I've done so far and I'm not sure why it's not working.

1) In /etc/apache2/httpd.conf I uncommented this this line:


2) In the httpd-vhosts.conf I put this:

NameVirtualHost *:80    

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "/Library/WebServer/Documents"

<VirtualHost *:80>
    ServerName work.local
    DocumentRoot "/Users/me/Work"
    <Directory /Users/me/Work>
        Order allow,deny
        Allow from all

3) Then I created an index.html in ~/Work

4) Finally I sudo apachectl restart ( I also restart it from Sharing in Sys Preference )

...but when I go to work.local it can't find it nor I can ping it.

$ ping work.local
ping: cannot resolve work.local: Unknown host

$ apachectl -S
httpd: Could not reliably determine the server's fully qualified domain name, using me-iMac.local for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server localhost (/etc/apache2/other/httpd-vhosts.conf:17)
         port 80 namevhost localhost (/etc/apache2/other/httpd-vhosts.conf:17)
Syntax OK
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

$ ping work.local

ping: cannot resolve work.local: Unknown host

The system does not the the IP of work.local

add work.local as hostname in /etc/hosts

see evt. this for dsn on lion http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/

share|improve this answer
That did it. Thanks! –  Pardoner Feb 3 '12 at 4:50
add comment

Your Answer


