setting up multiple virtual hosts in httpd.conf

CharanR
CharanR used Ask the Experts™
on
Hi,

There are 10 domain names that I'm hosting right now and I'm planning move all of its domain alias to centralized web server instance.  
I have created a new instance of apache, separated out config file (used Include) for each domain name for the aliases.

What could be the reason for the below warning
[Fri Jan 29 19:20:38 2010] [warn] NameVirtualHost 111.22.33.44:0 has no VirtualHosts
[Fri Jan 29 19:20:38 2010] [warn] NameVirtualHost 111.22.33.44:0 has no VirtualHosts

I have added the below code in mediainfo-com.conf
NameVirtualHost 111.22.33.44

<VirtualHost 111.22.33.44>

ServerName www.mediainfo.com
ServerAlias mediainfo.com

DocumentRoot /etc/www/httpd-mediainfo.com
RedirectMatch 301 ^/$ http://www.mediainfo.com/index.jsp

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.

ErrorLog /opt/services/apache/2.0/https-redirects.com/logs/mediainfo-com_error_log
TransferLog /opt/services/apache/2.0/https-redirects.com/logs/mediainfo_access_log
LogLevel warn

</VirtualHost>

<VirtualHost 111.22.33.44>

ServerName media.com
DocumentRoot /opt/services/htdocs/httpd-mediainfo.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mediainfo.com
#RewriteRule (.*) http://www.mediainfo.com$1 [R=301,L]

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
</VirtualHost>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
For name-based virtual hosts, you shouldn't need to list the IP address.

Try it in the format suggested at http://httpd.apache.org/docs/2.2/vhosts/name-based.html:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

I've done it like this on a number of virtual host setups, and I think I've only run into errors like yours when I tried putting the IP address in place of the asterisks.
Commented:
Note also that this is actually just a "warning" from apache, not an error.  I suspect apache is starting up for you, and is functioning as you wish, but the warning remains.
Commented:
Here's a copy of my config file for a linux apache2 with 2 virtual hosts. See if you can use this to help with your problem.

NameVirtualHost ip.address.to.host

<VirtualHost *:80>
        ServerAdmin admin@host.com
        ServerName main.FQDN.host.name
        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </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/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    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>


<VirtualHost main.FQDN.host.name>
      ServerAdmin admin@host.com
      ServerName main.FQDN.host.name
      DocumentRoot /var/www/
      <Directory />
            Options FollowSymLinks
            AllowOverride None
      </Directory>
      <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
      </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/error.log

      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn

      CustomLog /var/log/apache2/access.log combined

    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>

<VirtualHost second.FQDN.host.name>
        ServerAdmin admin@host.com
        ServerName second.FQDN.host.name
        DocumentRoot /gallery/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /gallery/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </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/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    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>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial