Hi,

I have apache2 running on Ubuntu 9.04. I am trying to set up vhosts. I have two files in sites-enabled there contents are:

<Directory /var/www/video>
    AllowOverride All
    Order Allow,Deny
    Allow from all

AddType text/html .htm
</Directory>

<VirtualHost *:80>
      DocumentRoot /var/www/video
      ServerName jvids.co.uk
      Serveralias www.jvids.co.uk
     ServerAdmin jameslovejoy1@googlemail.com
</VirtualHost>

That was called

and the other is called 000-default:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride all
		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>

I get this when restarting apache:

* Restarting web server apache2                                                [Sat Feb 20 15:01:42 2010] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Sat Feb 20 15:01:42 2010] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Sat Feb 20 15:01:42 2010] [warn] NameVirtualHost *:80 has no VirtualHosts
[Sat Feb 20 15:01:42 2010] [warn] NameVirtualHost *:80 has no VirtualHosts
 ... waiting ..[Sat Feb 20 15:01:47 2010] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Sat Feb 20 15:01:47 2010] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Sat Feb 20 15:01:47 2010] [warn] NameVirtualHost *:80 has no VirtualHosts
[Sat Feb 20 15:01:47 2010] [warn] NameVirtualHost *:80 has no VirtualHosts
                                                                         [ OK ]

What is wrong with it?

Dani AI

Generated

The restart messages point to two common vhost problems: (1) Apache's name‑based vhosting either isn't declared or is declared for a different address, and (2) multiple enabled site files are colliding as the default for port 80. On Ubuntu 9.04 (Apache 2.2) the usual causes are a missing or duplicated NameVirtualHost *:80, VirtualHost stanzas that don't match that address, or more than one site acting as the default for the same IP:port.

Useful diagnostics (run as root or with sudo):

apache2ctl -S
grep -R "NameVirtualHost" /etc/apache2
cat /etc/apache2/ports.conf
ls -l /etc/apache2/sites-enabled
apache2ctl -t

Typical fixes and checks:

  • Ensure ports.conf contains exactly one Listen 80 and exactly one NameVirtualHost *:80. Remove any duplicate NameVirtualHost lines.
  • Confirm every enabled site uses the same address (e.g. <VirtualHost *:80>) and has a unique ServerName. apache2ctl -S shows which vhost is treated as default and which file defines it.
  • If the stock default site (000-default) should not be the catch‑all, disable it with a2dissite 000-default (or rename/adjust it) so it does not overlap your intended site.
  • Keep <Directory> and access rules inside the appropriate <VirtualHost> so scope is clear and avoids unexpected overlaps.
  • After changes, run apache2ctl -t to test and then reload Apache.

's Webmin suggestion provides a GUI for these steps, but the commands above reveal the underlying cause and make it easy to remove the duplicate/default overlap that triggers those warnings.

My suggestion is to install webmin and use it to configure your virtual hosts. If that, for some reason is not an option, let me know and I'll tell you how to do it using the scripts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.