# SOLVED: Apache2 and vhosts

## fosstux

Hi!

I am having problems with apache 2.0.48 and virtual hosting.

My vhosts.conf contains:

 *Quote:*   

> 
> 
> <VirtualHost *>
> 
> ServerName www.linuxprox.org
> ...

 

But I only can access the domain that is at pos. 1.

What's wrong?

Please help.

Thanks.

----------

## DomiX

Hi  :Smile: 

Maybe missing section  NameVirtualHost 

http://httpd.apache.org/docs-2.1/mod/core.html#namevirtualhost

Bye

----------

## fosstux

nope, did not help.

----------

## fosstux

Hi!

Here is  my apache.conf:

 *Quote:*   

> ### /etc/apache2/conf/apache2.conf
> 
> ### $Id: apache2.conf,v 1.3 2003/09/25 02:20:48 woodchip Exp $
> 
> ###
> ...

 

And here is my vhosts.conf:

 *Quote:*   

> 
> 
> NameVirtualHost *:80
> 
> <VirtualHost *>
> ...

 

What am I missing for virtual hosting? When I enter any of the domainnames it always opens the first path.

Please help.

Thanks

----------

## fleed

Try:

<VirtualHost *:80>

Try:

VirtualDocumentRoot /var/www/localhost/htdocs/www.crparr.net

Also, what exactly are you seeing when you try going to the pages? What do you mean by first path?

----------

## fosstux

okay. I made the changes you suggested. But it still does not work.

The following happens:

No matter what domain I enter I always see the homepage of www.crparr.net (the first virtual host)

If I change the order (e.g. www.linuxprox.org is defined first), I get this site whatever I enter. So: It always loads the default site.

Please help.

Thanks

----------

## fosstux

Up to now, I dod not get vhosting running. Therefor I might downgrade to Apache 1.3.29-r1.

----------

## thecooptoo

have your virtualhosts as 

<VirtualHost *>

ServerName server1

DocumentRoot /var/www/server1/htdocs

</VirtualHost>

<VirtualHost *>

ServerName server2

DocumentRoot /var/www/server2/htdocs

</VirtualHost>

with an index.html in each .../htdocs/index.html

in your client /etc/hosts put 

 192.x.x.x    server1

(you server IP)

restart apache 

http://server1 should serve /var/www/server1/htdocs/index.html

once its working  from your LAN change server1 to www...... and the DNS will be don on the internet instead of your machine

also if you do 

cat /etc/ap	ache2/conf/common.....  |grep -v '#'

it takes all the comment lines out

----------

## fosstux

The Proble is solved.

Thanks a lot.

----------

## eltech

um .. not that am having this problem .. but its a great sign of consideration and your will to help others who may be having the same problem that you post how you fixed your problem ..

----------

## fosstux

Hi:

I solved the problem by editing the vhosts.conf

Here it is:

 *Quote:*   

> NameVirtualHost *:80
> 
> <VirtualHost *:80>
> 
> ServerName www.crparr.net
> ...

 

Thje last thing I did was to write the port number into the <VirtualHost *> tag.

Then I restarted apache2. But I still had problems. But then I didn't do nything at all for a week. Then I tried again - and it worked!!!!!!   :Cool: 

Hope that helps...

Bye

----------

