Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After upgrading to Lion 10.7.2 today, Apache virtual hosts are not working anymore. When I go to http://XYZ.localhost, it say "server not found".

I am using Apache on my Mac OS X Lion and until today, it was working fine. I can access http://localhost but I can't access http://XYZ.localhost

My /etc/hosts file is like below;

127.0.0.1   XYZ.localhost

My /etc/apache2/extra/httpd-vhosts.conf file is like below;

<VirtualHost *:80>
    ServerName XYZ.localhost
    DocumentRoot /Library/WebServer/Documents/XYZ
    <Directory /Library/WebServer/Documents/XYZ>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

I think I once had this problem too, after another OS X update, but I can't remember how I solved it.

Is it a user permission issue? Or is there something wrong with Apache or any other setting?

EDIT: It seems like my /etc/hosts file is not working correctly. Even if I add something like 127.0.0.1 apple.com it still goes to the real apple.com. Maybe this might help to solve the problem.

share|improve this question

migrated from serverfault.com Oct 13 '11 at 8:10

This question came from our site for professional system and network administrators.

    
Just a quick suggestion, try putting in Options FollowSymLinks within the <Directory> section. –  l'L'l Oct 13 '11 at 1:44
    
Thanks ioi, I added Options FollowSymLinks but still no change. It was working before the Lion 10.7.2 update. There might be something wrong with permissions or hosts or something. This is so nonsense. –  Burak Erdem Oct 13 '11 at 1:52
    
    
No problem. I've put an answer that might help, although as you've said your /etc/hosts is not working -- so maybe that's it. –  l'L'l Oct 13 '11 at 2:12
    
@quanta You are great, thank you so much. That solved my problem. Apple did change something with DNS and broke everything. If you answer my question, I would love to accept that as the correct answer. Thanks. –  Burak Erdem Oct 13 '11 at 2:24
show 1 more comment

1 Answer

You need this in your conf:

NameVirtualHost *:80

So it should look like:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName XYZ.local
DocumentRoot /Library/WebServer/Documents/XYZ
<Directory /Library/WebServer/Documents/XYZ>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

You may also need to edit your main httpd.conf to include the httpd-vhosts.conf

share|improve this answer
    
I have it in /etc/apache2/extra/httpd-vhosts.conf already. I just updated the question about hosts file. Maybe that might help. –  Burak Erdem Oct 13 '11 at 2:08
    
The hosts file seems like the culprit. –  l'L'l Oct 13 '11 at 2:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.