LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache2 - virtual host defaulting to default host (https://www.linuxquestions.org/questions/linux-server-73/apache2-virtual-host-defaulting-to-default-host-765534/)

slimjim 10-30-2009 05:55 AM

Apache2 - virtual host defaulting to default host
 
Hi,

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

technology.smeg.com/wiki

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

Similarly, browsing to technology.smeg.com gives the default site index page.

Here's /etc/apache2/sites-enabled/technology.smeg.com:

Code:

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

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:

Code:

<VirtualHost *:80>
with

Code:

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 01: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 07:47 PM.