Question:I’m using Apache 2 to host multiple site on a single host using Apache name based VirtualHost feature. However, Apache is displaying lots of warning as follows:
Performing sanity check on apache22 configuration:
[Portal Oct 05 06:59:34 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:34 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:34 2008] [warn] NameVirtualHost 81.aaa.www.yyy:80 has no VirtualHosts
Syntax OK
Stopping apache22.
Waiting for PIDS: 14968.
Syntax OK
Starting apache22.
[Portal Oct 05 06:59:36 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:36 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Portal Oct 05 06:59:36 2008] [warn] NameVirtualHost 81.aaa.www.yyy:80 has no VirtualHosts
How do I fix this warning and host multiple websites under UNIX / Linux Apache 2 webserver?
Answer: The NameVirtualHost directive is a required to configure name-based virtual hosts. Add this to your httpd.conf file to fix this issue. Open httpd.conf file:
# vi httpd.conf
Add NameVirtualHost as follows:
NameVirtualHost *:80
OR add server IP
NameVirtualHost 202.54.1.1:80
Save and close the file. Restart httpd web server under RHEL / Red Hat / Fedora / CentOS Linux:
# service httpd restart
OR type the following to restart Apache 2 under Debian / Ubuntu Linux:
# /etc/init.d/apache2 restart
Sample Apache 2 Virtual hosting configuration
If you want to maintain multiple domains/hostnames on your machine you can setup VirtualHost containers for them. Most configurations use only name-based virtual hosts so the server doesn’t need to worry about IP addresses. This is indicated by the asterisks in the directives below.
# 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>
🐧 43 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
is not working for me… really dont know why… its always taking the first entry…
my domain provider:
-----------halbgasse.at:
http://80.108.98.115
-----------hebron.at:
http://80.108.98.115
—————/etc/apache2/sites-available:
The NameVirtualHost *:80 directive should go in your httpd.conf – sites available is generally symlinks of the actual virtual hosts.
Thanks a lot.
NameVirtualHost *:80
It’s very usefull
yes it work
lol that was the trick .. thx you
Thanks. NameVirtualHost *:80 help with all my problems.
PS Sorry for my English =)
Yup, needed this reminder again when I migrated all my sites to a new VPS :)
# My Virtual Hosts Config File for Two Domains
NameVirtualHost *:80
ServerAdmin webmaster@theos.in
DocumentRoot “/usr/local/docs/theos.in”
ServerName http://www.theos.in
ServerAlias theos.in
ErrorLog “/var/log/theos.in-error_log”
CustomLog “/var/log/theos.in-access_log” common
ServerAdmin webmaster@nixcraft.com
DocumentRoot “/usr/local/docs/nixcraft.com”
ServerName http://www.nixcraft.com
ServerAlias nixcraft.com
ErrorLog “/var/log/nixcraft.com-error_log”
CustomLog “/var/log/nixcraft.com-access_log” common
When I configure the same file , I have a problem. I used Firefox, everytime I type http://www.theos.in or http://www.nixcraft.com, I only see mainpage (theos.in), no nixcraft.com
thx alot
every thing working fine now :)
I’ve read many forum-posts with really crazy answers to this error message. And this litte * fix it. Thanks.
Thanks very muchhhhhhhhhhhhhhhhhh
Hi all i don t understund why it s always the first entry that is taken into account ??
I don t understund at all
Please help me
thank dude. it works like magic.
Finally it fixed.
I’ve had this problem on an Ubuntu Server for the whole time I’ve been running it (about 18 months) and have just avoided using Apache on it since I couldn’t find a fix and it seemed to work fine everywhere else. Now its fixed and I can use it properly.
My eternal gratitude!!!!
Thanks a LOT!
simple and fantastic
NameVirtualHost *:80
:)
I want to say “Thanks a LOT”.
I have 15 days looking for a help, finally i found it.
Thank you so much For that post!
Hi,
Thanks for all. It’s up
Regards
Marc
If you use Ubutu 10.10 as server and have configured as they suppose
For example:
under apache2/sites-enabled/eww.test.de
with the content:
# —————–
# eww.test.de
# ——————————————————-
ServerName eww.test.de
ServerAlias eww.test.de
ServerAdmin admin@localhost
ErrorLog /var/log/httpd/test-error_log
CustomLog /var/log/httpd/test-access_log common
DocumentRoot /home/eww/local
…
and edit your /etc/apache2/apache2.conf to add “NameVirtualHost *:80”
beware that you don’t add this at the end of the file instead put it over
>Include httpd.conf< or add this directive in the httpd.conf.
It took some hours of "service apache2 restart" until I found it.
Oops, the blog eat my <
Again the eww.test.de content\
Terima kasih banyak ….. after many days i lookingfor this, i get the answer
simple but very important
NameVirtualHost *:80
Thankyu very much….:)
Thanks, this helps a lot.
Thanks, work fine for me.
If you find yourself really stuck with this error, make sure that ALL of your VirtualHosts’ port designators match the port designated on the NameVirtualHost directive!
For instance:
That will result in the Port Overlap error because your VHost port doesn’t match the NameVirtualHost port.
Oops, that last should have been:
Thanks man u saved me…..this virtual hosting made me almost crazy in last 2-3 month
Thanks for this info. I couldn’t figure out why my virtual host config was not working. The Apache error message is not very useful for this problem.
Thanks guy.
You have solved my problem.
Also remember, at least on Red-hat based distors, that all the site configurations are loaded from /etc/httpd/conf.d in alphabetical order making the first one the default virtual host.
Cheers..!!
You have resolve my problem.
For all of you who got problem.
This line : NameVirtualHost *:80 MUST be just before :
Thx for this tweak !
Greate!
Thanks!
Thank you!
Tahnks, just what I needed for my Ubuntu server
Thanks, that was what was missing :D
Thank you! You solved my configuration problem. Just googled and found this solution
Awesome, this totally helped me get set up. I upgraded to Mavericks in-place from Lion, and my Apache vhosts were completely fubared until I found your post. Thanks!
Thanks a lot!!!
Hey men, you saved my life !! Works great
thaaaaaaaaaaaaaaaaaaaaaanks. very helpful
Thank you for this solution…
NameVirtualHost *:80
….above my hosts
Thank you very much!!!
Thanks! its worked for my!
Thanks very much!