0

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

3 Answers 3

1

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.

0

<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.

1
  • also i keep getting [warn] NameVirtualHost *:0 has no VirtualHosts
    – ggpwjg
    Nov 20, 2009 at 23:09
0

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

NameVirtualHost *:80
<VirtualHost *:80>
    # ...
</VirtualHost>
1

You must log in to answer this question.