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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop




![Apache: [warn] _default_ VirtualHost overlap on port 80, the first has precedence Error and Solution](http://s13.cyberciti.org/images/shared/rp/3/9.jpg)









{ 13 comments… read them below or add one }
Virtual Host refers to the practice of running more than one web site (such as http://www.company1.com and http://www.company2.com) on a single machine. Virtual hosts can be “IP-based”, meaning that you have a different IP address for every web site, or “name-based”, meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user. Using virtual hosts, host several domains with a single web server. In this way, save the costs and administration workload for separate servers for each domain.
I have a fedora 14 server from godaddy. my website does not show up in the browser. I have 4 websites on this server. i restarted apache and get the no virtual host error.
I typed in # vi httpd.conf
and the screen was blank
What is the solution
thanks
check your present working directory,
try this:
vi /etc/httpd/conf/httpd.conf
also to restart apache try:
service httpd restart
or
/etc/init.d/httpd restart
Guy, it’s
nano /etc/apache2/apache2.conf
not /etc/apache2/httpd.conf like in your post.
Thanks for the write up
People learn basics !
It’s not vi or nano and it’snot /etc/apache2/httpd.conf or /etc/apache2/apache2.conf.
It’s whatever is right for the DISTRIBUTION you use !
simply doesn’t work as it is not closed? This on doesn’t work on CentOS 6. If we close it with , the httpd service doesn’t throw an error on restart at least.
This solution simply doesn’t work for me. I have 3 different virtual hosts on my server, and these instructions do not help me. This is what it looks like for me:
NameVirtualHost *:80
DocumentRoot /var/www/
ServerName [redacted]
ServerAlias http://www.redacted
DocumentRoot /var/[redacted]/
ServerName [redacted]
ServerAlias http://www.redacted
DocumentRoot /var/[redacted]/
ServerName [redacted]
ServerAlias http://www.redacted
After I run “sudo /etc/init.d/apache2 restart”, it says “[warn] NameVirtualHost *:80 has no VirtualHosts”. The problem must lie somewhere else. I’m using an Ubuntu 12.10 system.
And as usual, HTML markup in comments screws up web developer blogs.
The problem is your configuration .
You must wrap different virtual hosts in a
statement each like in here:
http://httpd.apache.org/docs/2.2/en/vhosts/examples.html
That was not the problem. (The comment system here messed up my comment because I used angle brackets.) I did have the different VirtualHost declarations in separate scopes. The problem was instead that I had declared “NameVirtualHost *:80″ twice, once in apache2.conf and once in ports.conf.
Check to see if you have NameVirtualHost *:80 twice in you apache confs.