Apache2 - how to configure 2 virtual hosts (name based)

Hi All,

I am new to Linux, started a week ago to install debian woody than decided to go with Sarge. All went reasonably OK with the ADLS proxy IPTables Apache, etc. Now I have decided to install apache2. So I did. And here I am trying to configure two virtual hosts.

Primarily I cant beleive the way the information is presented in the documentation, but I can't even find what I need...

The old Apache config was simple. Two sections related to the two virtual hosts had to be added in httpd.conf and that was it....

Now I dont even know where should it go. The information I have found (in doc and exaples on the net ) is conflicting at best

Consider I have two domains, domain1.com.au and domain2.com.au. Both are set up on the same IP address and ports, what and where should go... assuming that I have a completely clean install of Apache2 on Debian Sarge.

TIA,

Tom
tom_szaboAsked:
Who is Participating?
 
arjecahnConnect With a Mentor Commented:
Apache.conf is probably your httpd.conf file.
What happens if you take out the Include statement and restart Apache? Does it still give the error?
If it doesn't, you're sure it's in one of the included files.
BTW, what files do you have in sites-enabled?
0
 
caterham_wwwConnect With a Mentor Commented:
> Two sections related to the two virtual hosts had to be added in httpd.conf and that was it....

Open /etc/apache2/httpd.conf (which might be empty) and place there


NameVirtualHost *

<VirtualHost *>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName domain1.com.au
    ServerAlias www.domain1.com.au
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost *>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName domain2.com.au
    ServerAlias www.domain2.com.au
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

0
 
tom_szaboAuthor Commented:

I have added this to httpd.conf:

NameVirtualHost *

<VirtualHost *>
    ServerAdmin webmaster@ifss.com.au
    DocumentRoot /var/www/ifss.com.au/docs/
    ServerName ifss.com.au
    ServerAlias www.ifss.com.au
    ErrorLog /var/www/ifss.com.au/logs/error.log
    CustomLog /var/www/ifss.com.au/logs/access.log common
</VirtualHost>

<VirtualHost *>
    ServerAdmin webmaster@gotomypc.com.au
    DocumentRoot /var/www/gotomypc.com.au/docs/
    ServerName gotomypc.com.au
    ServerAlias www.gotomypc.com.au
    ErrorLog /var/www/gotomypc.com.au/logs/error.log
    CustomLog /var/www/gotomypc.com.au/logs/access.log common
</VirtualHost>

..and I get this:

Reloading web server config...[Mon Apr 11 10:25:32 2005] [warn] NameVirtualHost*:0 has no VirtualHosts
done.

Why?
What else is missing?

TIA,

Tom
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
arjecahnCommented:
Try adding
<VirtualHost *:80>

Do you have "Listen" set correctly?
Set it, above your VirtualHosts declarations, to

Listen 0.0.0.0:80
0
 
tom_szaboAuthor Commented:
No, sorry but did not help, the message is still there!
0
 
tom_szaboAuthor Commented:
Should correct, it actually did not even work, could not start the server if either of those were added!

0
 
arjecahnCommented:
Tom, could you post your full httpd.conf?
0
 
tom_szaboAuthor Commented:
That is it!

The original Apache.conf has not been touched. This is all what I have added....

The server seem to work, but comes up with the message...
0
 
tom_szaboAuthor Commented:
This si something I don't understand:
.....
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/[^.#]*


This is the end of the Apache2.conf file, and it means (to me) that now we include the files in the Sites-enabled folder. That is left untouched also.

But where is the include for the httpd.conf??? or is that automatic?
0
 
tom_szaboAuthor Commented:
The solution is that one has to remove the line

>> NameVirtualHost *

from httpd.conf and move this one line into apache.conf and make sure that there is no more in the config files...

thanks the help anyway
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.