Apache Virtual Hosts on Mac OS X Lion

11,741

In both your localhost and site2.local <virtualHost> declarations you have a . (dot) instead of a : (colon).

They should both be

<VirtualHost *:80>
Share:
11,741

Related videos on Youtube

Bullines
Author by

Bullines

cod'r #SOreadytohelp

Updated on September 18, 2022

Comments

  • Bullines
    Bullines almost 2 years

    In /etc/apache2/extra/httpd-vhosts.conf, I have:

    NameVirtualHost *:80
    
    <VirtualHost *.80>
        ServerName localhost
        DocumentRoot "/Library/WebServer/Documents"
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerName site1.local
        DocumentRoot "/Users/bob/Sites/site1.local"
        <Directory /Users/bob/Sites/site1.local>
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    
    <VirtualHost *.80>
        ServerName site2.local
        DocumentRoot "/Users/bob/Sites/site2.local"
        <Directory /Users/bob/Sites/site2.local>
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    

    In /etc/hosts, I have:

    127.0.0.1     site1.local
    127.0.0.1     site2.local
    

    Browsing to http://site1.local yields the correct site. However, browsing to http://site2.local displays Site1's content.

    Did I mis-configure something?

  • Bullines
    Bullines almost 13 years
    Good eye :) That was it.