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.

Help!

I'm trying to convince my Apache to point localhost to /Sites. What am I doing wrong?

httpd.conf settings

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<VirtualHost *>
    DocumentRoot "/Users/username/Sites"
    ServerName localhost
</VirtualHost>
  • DocumentRoot points to /Sites folder.
  • Listen 80
  • NameVirtualHost *

Buggy Result

  1. 10.0.0.4 results with /Sites folder.
  2. 127.0.0.1 does the same.
  3. ERROR: http://localhost results with /private/etc/apache2/.../htdocs
share|improve this question

3 Answers 3

I'm writing this shamefully, just for one reason: I found a thread with that question exactly, that ended with the user asking the questions saying "Got it working. Too ashamed to say what was the problem".

I nearly killed myself.

listen localhost:80

That's what I've been missing the whole time. There, for future generations. Amen.

share|improve this answer
    
At least I got a glimpse inside Apache's famous gut configuration. Gotta look on the bright side of bugs. –  konzepz Sep 30 '09 at 20:27

What does localhost resolve to? It could legitimately be the IPv6 ::1, or anything in 127.0.0.0/8.

share|improve this answer
    
I have both of these (::1 localhost / 127.0.0.1 localhost) in .hosts file. –  konzepz Sep 30 '09 at 19:28

Without more info, I can't say exactly why this is happening. Apache is sensitive to the order in which virtual hosts are specified in its configuration. However, I'd use here. Unless you want other name-based virtual hosts on 127.0.0.1.

Also, it may be useful for you to use the following command to see what Apache thinks of your virtual host configuration:

apache2 -t -D DUMP_VHOSTS

Depending on your particular system, the "apache2" command may be something else, like "httpd". If you're running Windows, I don't know if it will work at all.

share|improve this answer
    
DUMP_HOSTS gives: : is a NameVirtualHost | default server localhost (/private/etc/apache2/extra/httpd-vhosts.conf:36) | port * namevhost localhost (/private/etc/apache2/extra/httpd-vhosts.conf:36). Looks okay. The httpd-vhosts.conf is set as I mentioned in the question. What to do now? –  konzepz Sep 30 '09 at 20:21

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.