Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have the following in my sites-enabled:

#
#  Example.com (/etc/apache2/sites-available/adityaherlambang.com)
#
<VirtualHost *:80>
        ServerAdmin webmaster@adityaherlambang.com
        ServerName  www.adityaherlambang.com
        ServerAlias adityaherlambang.com

        # Indexes + Directory Root.
        DirectoryIndex index.html
        DocumentRoot /var/www/adityaherlambang.com/htdocs/

        # CGI Directory
        ScriptAlias /cgi-bin/ /var/www/adityaherlambang.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /var/www/adityaherlambang.com/logs/error.log
        CustomLog /var/www/adityaherlambang.com/logs/access.log combined
</VirtualHost>

In my virtual.conf I have:

#  We're running multiple virtual hosts.
#

NameVirtualHost *:80

I was just following the tutorial here. Why is it that now when I restart my server I am getting:

 * Restarting web server apache2                                                                                                                             [Sun Aug 14 04:35:30 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
[Sun Aug 14 04:35:30 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
 ... waiting .......[Sun Aug 14 04:35:42 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
[Sun Aug 14 04:35:42 2011] [warn] NameVirtualHost *:80 has no VirtualHosts

My etc hosts looks like:

#127.0.0.1 localhost
127.0.0.1.:80 adityaherlambang.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
share|improve this question
    
That /etc/hosts is... well, polite words fail me. I'll go with "wrong", at the risk of understating the problem too much. –  womble Aug 14 '11 at 4:46
    
so how do I fix that? –  EquinoX Aug 14 '11 at 5:08

2 Answers 2

up vote 3 down vote accepted

VirtualHost does not have a default port; when you say <virtualHost *> you mean all ports on all addresses. You need to use *:80 instead.

share|improve this answer
    
why does the tutorial shows it like that? –  EquinoX Aug 14 '11 at 5:09
    
The tutorial doesn't show it like you've implemented it. –  womble Aug 14 '11 at 5:11
    
before this I used NameVirtualHost * and <virtualHost *:80> and it didn't work as well –  EquinoX Aug 14 '11 at 5:13
    
and even after changing that.. I am still getting * Restarting web server apache2 [Sun Aug 14 05:14:51 2011] [warn] NameVirtualHost *:80 has no VirtualHosts ... waiting [Sun Aug 14 05:14:52 2011] [warn] NameVirtualHost *:80 has no VirtualHosts –  EquinoX Aug 14 '11 at 5:15

Ignacio was correct, but I just wanted to expand.

If you take a look at the docs for NameVirtualHost. You can see the syntax calls for an IP and then a port. This doesn't mean Apache will listen on the port you specify here, or even if you just use NameVirtualHost * doesn't mean it will listen to every port. Apache has the Listen directive which defines which port Apache listens on.

By setting NameVirtualHost *:80 What you are doing is saying on all request that come in on port 80, run it through name-based virtual hosting. So if you just had NameVirtualHost * your telling apache that not matter where the request come from, run it through name-based virtual hosting. If specified an IP, then only that IP would be subject to virutalhost.

So the easy answer would be always have your NameVirtualHost match your virtual host. But I think understanding why is important. Because one day you might have that crazy server where it has Listen 80 8080 81 and NameVirtualHost is only set up on 8080 and 81?? Could happen.

share|improve this answer

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.