Monday, April 23, 2012

Apache2 NameVirtualHost *:80 has no VirtualHosts Error and Solution

Whenever I try to star my Apache 2 server under UNIX / Linux and get a warning as follows:
[warn] NameVirtualHost *:80 has no VirtualHosts
How do I fix this problem?

The NameVirtualHost directive is a required to configure name-based virtual hosts. You need edit your Apache configuration file httpd.conf or apache2.conf, enter:
# vi httpd.conf
Find line that read as follows:
 
<VirtualHost *>
 
Replace is at follows:
 
NameVirtualHost *:80
<VirtualHost *:80>
 
Save and close the file. Here is the sample config file:
 
# My Virtual Hosts Config File for two Domains
NameVirtualHost *:80
 
<VirtualHost *:80>
ServerAdmin webmaster@theos.in
DocumentRoot "/usr/local/docs/theos.in"
ServerName www.theos.in
ServerAlias theos.in
ErrorLog "/var/log/theos.in-error_log"
CustomLog "/var/log/theos.in-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
ServerAdmin webmaster@nixcraft.com
DocumentRoot "/usr/local/docs/nixcraft.com"
ServerName www.nixcraft.com
ServerAlias nixcraft.com
ErrorLog "/var/log/nixcraft.com-error_log"
CustomLog "/var/log/nixcraft.com-access_log" common
</VirtualHost>
 
Save and close the file. Finally, restart Apache:
# /etc/init.d/apache2 restart
OR
# service httpd restart

No comments:

Post a Comment