# Apache virtual hosts

## jaeger_m

Hi...

So, for a long time now, I've got a little apache problem...

I've got the domain www.entertainment-zone.de, and i'd like to run some vhosts on it, i.e. forum.entertainment-zone.de

To do this, I've made the following config in /etc/apache/conf/vhosts/Vhosts.conf:

NameVirtualHost 213.17.197.130

<VirtualHost 213.17.197.130>

ServerName forum.entertainment-zone.de

ServerAdmin info@entertainment-zone.de

DocumentRoot /home/httpd/httpdocs/forum/

User web

Group web

</VirtualHost>

now, if I try to reach forum.entertainment-zone.de, I am directed to /home/httpd/httpdocs/ and not to /home/httpd/httpdocs/forum/

Why is that?

----------

## magnet

this seems ok.do you have anything in the log that could be usefull ?

do you have forum.entertainment-zone.de  resolving to the right ip ?

----------

## handsomepete

Try changing 

```
<VirtualHost 213.17.197.130>
```

to

```
<VirtualHost *>
```

If that doesn't help try adding a "ServerPath /" in your VirtualHost setup.  I can't remember if that actually does something or not...

----------

## jaeger_m

ok, so my conf is now:

NameVirtualHost 213.17.197.130

<VirtualHost *>

ServerName forum.entertainment-zone.de

DocumentRoot /home/httpd/httpdocs/forum/

User web

Group web

</VirtualHost>

http://forum.entertainment-zone.de/ gives:

 *Quote:*   

> Forbidden
> 
> You don't have permission to access / on this server.

 

error_log says:

[Fri May 23 18:12:57 2003] [error] [client 62.220.8.64] client denied by server configuration: /home/httpd/httpdocs

and apache start says:

[Fri May 23 18:12:33 2003] [warn] NameVirtualHost 213.17.197.130:80 has no VirtualHosts

The IP is resolved correctly.

----------

## handsomepete

/home/httpd/httpdocs/forum/ must be owned by web/web if you're including a user and group in your config but must still be world viewable (at least I think that's how it works).  Here's my Vhosts.conf (with some info changed for public consumption).  It works great.

```
Port 80

ServerRoot /etc/apache

ResourceConfig /dev/null

AccessConfig /dev/null

NameVirtualHost my.ip.is.here

<VirtualHost *>

 ServerName myserver.com

 ServerAlias www.myserver.com

 ServerPath /

 DocumentRoot /home/httpd/www/serverdirectory

</VirtualHost>
```

With /home/httpd/www/serverdirectory owned by root/root and world readable and executable.

----------

## Durenunde

just out of curiousity, is it not supposed to be

/home/httpd/htdocs/forums

as thats the way my one reads, you have

/home/httpd/httpdocs/forum/ 

if that isnt right it will default to / as far as I know I think I made that mistake before also... unless you changed the path yourself?

check your path is correct and also try putting chmod 777 on your forums folder just to see if that changes anything then you can change it back

----------

## idiotprogrammer

1. run the command "hostname" from your command line. What do you see? 

I had a similiar problem with multiple virtual hosts until I changed my hostname in etc/hosts to www.mydomain.com

2. For my config file, all the virtual servers went to a single ip address. In that case, you can  do 

NameVirtualHost * 

(and just do the same thing  for IP addresses on all your virtual servers). That worked for me. 

When you run "apachectl configtest" do you see any error messages.? 

You can read about my agony here http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=fbef97c.0305082119.1d6894a8%40posting.google.com&rnum=1&prev=/groups%3Fq%3Didiotprogrammer%2540yahoo.com%26num%3D100%26hl%3Den%26scoring%3Dd

Hope this helps.  BTW, I emerged "webmin" (a browser based way to configure apache and lots of other things). Works great! 

Robert Nagle, Idiotprogrammer

----------

## jaeger_m

OK, doing some progress...

I guess I have a more general problem.

Waht I want:

http://www.entertainment-zone.de/

-> docRoot should be /home/httpd/htdocs/

http://forum.entertainment-zone.de/

-> docRoot should be /home/httpd/htdocs/forum/

http://www.somethingelse.de/

-> docRoot should be /home/httpd/htdocs/somethingelse/

What should a vhosts file for this look like?

Thanx for the help!

----------

## tagore

try this :

 *Quote:*   

> 
> 
> NameVirtualHost 213.17.197.130
> 
> #######################################################################
> ...

 

in my server work like a charm ... try , and comment if this work  :Smile: 

I'm change the patch of the sites .... so that but it is ordered.

cheers.

----------

## jaeger_m

OK, I've modifyed it slightly to fit my dir structure:

 *Quote:*   

> 
> 
> NameVirtualHost 213.17.197.130
> 
> #######################################################################
> ...

 

I'vbe commented out somethingelse.de for the moment...

But it still doesn't work...

BTW:

 *Quote:*   

> 
> 
> www root # ls -la /home/httpd/
> 
> total 40
> ...

 

Sometimes I've got the feeling i'm cursed...

----------

## Durenunde

I was glad I bought "sams teach yourself apache in 24 hours" before I got into this... a very good buy  :Wink: 

but also try * where-ever you put your IP address if you are computer on a network behind that it sometimes doesnt like it

 *Quote:*   

> ####################################################################### 
> 
> # forum.entertainment-zone.de 
> 
> ####################################################################### 
> ...

 

you shouldnt need all that I've got virtual hosting with some very simple stuff all you need is the basics

here try this

 *Quote:*   

> ####################################################################### 
> 
> # forum.entertainment-zone.de 
> 
> ####################################################################### 
> ...

 

that is basically what my one is like

----------

