# vhosts.conf not being read properly: apache2

## chovy

 *Quote:*   

> xxx apache2 # /etc/init.d/apache2 restart
> 
>  * Restarting apache2 ...
> 
> [Tue May 03 13:11:16 2005] [warn] NameVirtualHost *:80 has no VirtualHos  [ ok ]

 

Here is a vhost.conf file:

 *Quote:*   

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

 

These don't appear to be working, the only thing that is working is the catchall in httpd.conf:

 *Quote:*   

> 
> 
> <VirtualHost *:80>
> 
>     #
> ...

 

From error_log after requesting xxx.com/test:

 *Quote:*   

> [Tue May 03 13:21:22 2005] [error] [client 216.113.168.128] File does not exist: /var/www/localhost/htdocs/test

 

Notice it's not going to /var/www/xxx.com/htdocs/test when I request www.xxx.com/test

----------

## Insanity5902

I would take comment out all of that stuff, I don't think you need it.

Secondly, there is an include you need to uncomment in the conf that includes the vhost file you are editing.

mine looks like this

```
Include conf/vhosts/vhosts.conf
```

this includes thin file in /etc/apache2/conf/vhosts/vhosts.conf, be default this line is commented out.

----------

## chovy

I got it working.

ServerName in the main conf was conflicting with ServerName in VirtualHost.

Also needed to uncomment "EnableSendFile off"

----------

## tscolari

 *chovy wrote:*   

> I got it working.
> 
> ServerName in the main conf was conflicting with ServerName in VirtualHost.
> 
> Also needed to uncomment "EnableSendFile off"

 

what do you mean?

Im having the same problem here, but i have no idea why, never got this before...

"[warn] NameVirtualHost *:80 has no VirtualHosts"

in httpd.conf there is a include for: Include /etc/apache2/vhosts.d/*.conf

so I open a vhost.d/00_default_vhost.conf (the only file there) and find this:

```

NameVirtualHost *:80

...

<IfDefine DEFAULT_VHOST>

<VirtualHost *:80>

    DocumentRoot "/var/www/localhost/htdocs"

...

```

can someone help me?

----------

## chovy

```
httpd.conf

ServerName foo

vhosts.conf

<VirtualHost  *:80>

00_default_vhost.conf

NameVirtualHost *:80

```

I just upgraded to latest apache2, and this is how it works now for me.

----------

## SoreGums

 *tscolari wrote:*   

> 
> 
> Im having the same problem here, but i have no idea why, never got this before...
> 
> "[warn] NameVirtualHost *:80 has no VirtualHosts"
> ...

 

I just installed gentoo and emege apache2, and got the above warn, went into the 00_default_vhost.conf and removed these 2 lines:

```

...

<IfDefine DEFAULT_VHOST>

...

</IfDefine>

...

```

No more warning and /usr/sbin/apache2 -S actually shows Vhosts....

So either we are suppose to make/define DEFAULT_VHOST true somewhere or this is a left over from something

EDIT: But apache still wont start

 *Quote:*   

> gentoo ~ # /usr/sbin/apache2 -t
> 
> Syntax OK
> 
> gentoo ~ # /etc/init.d/apache2 start
> ...

 

EDIT2: Hehe found something...

http://www.gentoo.org/doc/en/apache-troubleshooting.xml#doc_chap6

Edit3: Except it is defined...

 *Quote:*   

> APACHE2_OPTS="-D DEFAULT_VHOST PHP4"

 

Edit4: So lots of fiddling later i've figured out I needed this

 *Quote:*   

> APACHE2_OPTS="-D DEFAULT_VHOST -D PHP4"

 

----------

