-   Linux - Server (
-   -   Apache2 - virtual host defaulting to default host (

slimjim 10-30-2009 06:55 AM

Apache2 - virtual host defaulting to default host

Bit of an odd one, this. I've migrated a website from my old server to a new machine. Both servers run Ubuntu + Apache2. Both only serve a single site, apart from the default site.

I've flipped the domain name to the new IP address.

The trouble is that after moving the virtual host config over into sites-available, with the necessary link in sites-enabled, Apache attempts to serve from the default web root (/var/www) rather than the actual site content (in /var/www/technology). So for example, an attempt to browse to

.. gives a 404, and a message in the error log shows that it attempted to find /var/www/wiki.

Similarly, browsing to gives the default site index page.

Here's /etc/apache2/sites-enabled/


<VirtualHost *>
ScriptAlias /support/ /usr/lib/cgi-bin/
ScriptAlias /lookuptable/ /usr/lib/cgi-bin/
AddHandler cgi-script .cgi
DocumentRoot /var/www/technology

Now, I can "fix" this by removing the 000-default entry from sites-enabled. If I do that, Apache will serve the correct content from /var/www/technology.

But that kills the default site, which I want to keep, and I didn't have to do that on the old box. It also destroys some default settings used by the virtual host, I think.

I've changed the domain name to protect the innocent.

Any ideas?

.. ah never mind .. just fixed it! I noticed that the 'default' file linked from 000-default is different on the older server. When I replaced the line:


<VirtualHost *:80>


NameVirtualHost *
<VirtualHost *>

.. to match the old server, then restarted - it all works.

Will post this anyway, in case it helps someone else.

Wim Sturkenboom 10-31-2009 02:47 AM

To get this of the zero-reply list

Thanks for the solution. Can you please mark the tread as solved using the thread tools just above the first post; this might help others that are looking or solutions for the same problem.

All times are GMT -5. The time now is 11:17 AM.