NameVirtualHost www.mysite.it has no VirtualHosts

Discussion in 'Server Operation' started by gabrix, Feb 1, 2007.

  1. gabrix

    gabrix New Member

    I have 3 virtualhosts on an apache2 running on a debian 2.6.8 stable . I don't understand why the site still being reachable , when i restart apache2 , it shows this error:
    Code:
    root@www:~# /etc/init.d/apache2 restart
    Forcing reload of web server: Apache2[Thu Feb 01 10:13:45 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
    [Thu Feb 01 10:13:45 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
    It happens only for the site above , and all sites have same virtualhost in pache2.conf and dir /etc/apache2/sites-enabled here the apache2.conf:
    Code:
    <VirtualHost tor.gabrix.ath.cx>
         ServerName tor.gabrix.ath.cx
         ServerAlias tor.gabrix.cx
         ServerAdmin gabrix@gabrix.ath.cx
         DocumentRoot /var/www/torgab
         ErrorLog /var/log/apache2/tor_error.log
         TransferLog /var/log/apache2/tor_access.log
    <IfModule mod_security.c>
         CustomLog /var/log/apache2/tor_modsec_custom_log \
            "%h %l %u %t \"%r\" %>s %b %{mod_security-message}i" \
            env=mod_security-relevant
    </IfModule>
    </VirtualHost>
    
    <VirtualHost www.gabrix.ath.cx>
         ServerName www.gabrix.ath.cx
         ServerAlias www.gabrix.cx
         ServerAdmin gabrix@gabrix.ath.cx
         DocumentRoot /var/www/gabrix
         ErrorLog /var/log/apache2/gabrix_error.log
         TransferLog /var/log/apache2/gabrix_access.log
    <IfModule mod_security.c>
         CustomLog /var/log/apache2/gabrix_modsec_custom_log \
            "%h %l %u %t \"%r\" %>s %b %{mod_security-message}i" \
            env=mod_security-relevant
    </IfModule>
    </VirtualHost>
    
    <VirtualHost x.gabrix.ath.cx>
         ServerName x.gabrix.ath.cx
         ServerAlias x.gabrix.cx
         ServerAdmin gabrix@gabrix.ath.cx
         DocumentRoot /var/www/ics
         ErrorLog /var/log/apache2/x_error.log
         TransferLog /var/log/apache2/x_access.log
    <IfModule mod_security.c>
         CustomLog /var/log/apache2/x_modsec_custom_log \
            "%h %l %u %t \"%r\" %>s %b %{mod_security-message}i" \
            env=mod_security-relevant
    </IfModule>
    </VirtualHost>
    And this is the /etc/apache2/sites-enabled/ics file:
    Code:
    NameVirtualHost x.gabrix.ath.cx
    <VirtualHost x.gabrix.ath.cx>
    	ServerAdmin webmaster@gabrix.ath.cx
    	
    	DocumentRoot /var/www/ics
    	<Directory />
    		Options FollowSymLinks
    		AllowOverride None
                    Order allow,deny
                    allow from 127.0.0.1/8
                    allow from 192.168.1.0/29
                    deny from all
    	</Directory>
    	<Directory /var/www/ics/>
    		Options Indexes FollowSymLinks MultiViews
    		AllowOverride None
    		Order allow,deny
    		allow from all
    		# This directive allows us to have apache2's default start page
                    # in /apache2-default/, but still have / go to the right place
    		#RedirectMatch ^/$ /apache2-default/
    	</Directory>
    
    	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    	<Directory "/usr/lib/cgi-bin">
    		AllowOverride None
    		Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
    		Order allow,deny
    		Allow from all
    	</Directory>
    
    	ErrorLog /var/log/apache2/x_error.log
    
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel warn
    
    	CustomLog /var/log/apache2/x_access.log combined
    	ServerSignature Off
    
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>
    
    </VirtualHost>
    This morning i added the first page of content and i had back a "page not found" but maybe it's an another issue .
    ciao.
     
  2. falko

    falko Super Moderator

    Code:
    NameVirtualHost x.gabrix.ath.cx
    NameVirtualHost must be followed by an IP address, not an FQDN.
     
  3. gabrix

    gabrix New Member

    Why x.gabrix.ath.cx is the only between them 3 to have an ip ? Anyway didn't work like this either ...
     
  4. falko

    falko Super Moderator

    You must change all NameVirtualHost directives. Each of them must take an IP address.
     
  5. gabrix

    gabrix New Member

    Forgive me i changed configuration in all possible maners, but i don't manaage to get it to work.Where should the ip go in the apache2.conf file or sites-enabled dir ?
    Ho i sould i configure the default virtualhost ? with a * or ip ?And where does the NameVirualHost directive go ?
     
  6. martinfst

    martinfst HowtoForge Supporter

    You should update both NameVirtualHost and VirtualHost. You can use a *, and as such it will be active for every IP on your system, of you can use a single IP, in which case the block is only valid for that IP address
    Code:
    [COLOR="Red"]NameVirtualHost *
    <VirtualHost *>[/COLOR]
            ServerAdmin webmaster@localhost
            
            DocumentRoot /var/www
            <Directory />
                    Options None
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/>
                    Options None
                    #Options Indexes FollowSymLinks MultiViews
                    Options FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
                    # Uncomment this directive is you want to see apache2's
                    # default start page (in /apache2-default) when you go to /
                    #RedirectMatch ^/$ /apache2-default/
            </Directory>
    
            ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <snipped rest of file>
    
     
  7. gabrix

    gabrix New Member

    That's how i have set the 3 virtualhost on my apache2
    And i keep on getting this error:
    Do i have to name also the port it listen to ?Is it because the default virtualhost has to be mensioned explicitly ?
    Still with yhe default virtualhost on *.
    I get the error:
     
    Last edited: Feb 4, 2007
  8. martinfst

    martinfst HowtoForge Supporter

    Maybe you're making the modifications to the config file apache2 is not using? See
    Code:
    httpd -V
    for the initial config file and work from there.
     
  9. gabrix

    gabrix New Member

    What's that httpd -V it is apache2 in charge ....
     
  10. martinfst

    martinfst HowtoForge Supporter

    Yes, and httpd is the name of the Apache(2) program actually running. You will see when you execute the command.
     
  11. falko

    falko Super Moderator

    That warning is ok, it just means that there is no virtual host on the IP address 192.168.1.4.
     
  12. gabrix

    gabrix New Member

    My virtual hosts are configured just like as you see in my first post and instead of fqdn there are ips as you sayd so it's not ok !!!
     
    Last edited: Feb 5, 2007
  13. martinfst

    martinfst HowtoForge Supporter

    So what's the output of
    Code:
    apache2ctl -V
    then?
     
  14. gabrix

    gabrix New Member

    This has worked :
     
  15. martinfst

    martinfst HowtoForge Supporter

    So you use
    for you config file. Good. In your 1st post you showed us (part of?) this file. Can you check if you have a line reading
    Code:
    Include /etc/apache2/sites-enabled/[^.#]*
    in this apache2.conf file?
     
  16. gabrix

    gabrix New Member

    Here it is:
    And this is the virtualhost file:
     
  17. falko

    falko Super Moderator

    What exactly is the problem right now? Don't your sites work now?
     
  18. frgomes

    frgomes New Member

    Try updating /etc/hosts

    If you are behind a NAT/firewall, probably your webserver has a local IP address (probably 192.168.xxx.xxx) and your router/firewall is responsible for forwarding incoming requests to your webserver.

    In this situation, you have a public IP address for your www.yourdomain.com but, in fact, Apache has to accept requests in your local interface instead of your public IP address (assigned to your router/firewall in fact).

    Try something like this in your /etc/hosts:


    Code:
    127.0.0.1 localhost
    
    # these lines MUST be kept otherwise Apache2 fail serving these addresses
    192.168.1.2 subdomain11.yourdomain1.com
    192.168.1.2 subdomain12.yourdomain1.com
    192.168.1.2 subdomain13.yourdomain1.com
    192.168.1.2 subdomain21.yourdomain2.com
    192.168.1.2 subdomain22.yourdomain2.com
    192.168.1.2 subdomain23.yourdomain2.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
    
    Enjoy :)
     
  19. gabrix

    gabrix New Member

    I have done this the problem remains !!!!
     
  20. tftd

    tftd New Member

    Hello there ..
    I have the same problem. I'm reading almost everything in the network about it and still under apache 1.3.37 it doesn't work.

    My NameVirtualHost is the IP of the machine. For example

    NameVirtualHost 123.123.123.123:80

    <VirtualHost 123.123.123.123:80>
    Documen Root /somewhere/subdomain
    ServerName www.subdomain.mydomain.com
    ErrorLog logs/bla.error_log
    </VirtualHost>


    And I get the error:

    [Fri Mar 23 02:25:42 2007] [warn] NameVirtualHost 123.123.123.123:80 has no VirtualHosts
    /usr/local/apache/bin/apachectl start: httpd started
     

Share This Page