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.

my default virtual host which loads mainsite.com

NameVirtualHost *
<VirtualHost *>


        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
</VirtualHost>

another virtual host i added so when i go to myothersite.com it will load

NameVirtualHost *
<VirtualHost *>
    ServerName myothersite.com
    DocumentRoot /var/www/myothersite.com

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
</VirtualHost>

I have already added A record to my server ip for myothersite.com.

I restarted apache server but myothersite.com will not load. I get server not found.

when restarting i get [warn] NameVirtualHost *:0 has no VirtualHosts

share|improve this question
add comment

3 Answers

The following snippet should definitely work:

NameVirtualHost *
<VirtualHost *>
  DocumentRoot /var/www/
  # ...
</VirtualHost>

<VirtualHost *>
  ServerName myothersite.com
  DocumentRoot /var/www/myothersite.com
  # ...
</VirtualHost>

See how NameVirtualHost occurs only once while multiple <VirtualHost> directives can refer to it.

You could also use NameVirtualHost *:80 or NameVirtualHost <IP address>:80 if you wanted to be more specific. For details read the documentation on Apache httpd's Name-based Virtual Host Support.

Since you mentioned an error message like "Server not found" it is more likely that you have a DNS problem with your domain. Check again if the domains are properly setup in your name server.

share|improve this answer
add comment

<VirtualHost *:80>
ServerName drongo.zarack.com
ServerAlias drongo.zarack.com
DocumentRoot /var/www/html
DirectoryIndex index.html index.php
</VirtualHost>

This is my working conf file.

Also, check the A record has propergated to your DNS Server by nslookup myothersite.com and confirm you are getting the value your expecting.

Just as a side, I have found to good station keeping, I put a CNAME for virtual names and A for actual hosts.

share|improve this answer
    
also i keep getting [warn] NameVirtualHost *:0 has no VirtualHosts –  ggpwjg Nov 20 '09 at 23:09
add comment

Make sure to use *:80 in both NameVirtualHost and VirtualHost:

NameVirtualHost *:80
<VirtualHost *:80>
    # ...
</VirtualHost>
share|improve this answer
    
'*' as a wildcard is also a valid argument for NameVirtualHost and <VirtualHost> (see httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost). –  joschi Dec 21 '09 at 12:53
add comment

Your Answer

 
discard

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