LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache 2.2 won't recognize virtual hosts (https://www.linuxquestions.org/questions/linux-server-73/apache-2-2-wont-recognize-virtual-hosts-520064/)

gregmcavoy 01-17-2007 03:02 AM

Apache 2.2 won't recognize virtual hosts
 
When I run Apache 2.2 (Debian Etch new instal) with its default apache2.conf, it runs fine. But when I add a virtual host to the httpd.conf file:

Code:

Listen 80
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName example.hopto.org
  ServerAlias *.example.hopto.org
  DocumentRoot /var/www/example
</VirtualHost>

i get errors:

Code:

# apache2ctl restart
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Wed Jan 17 00:51:23 2007] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Wed Jan 17 00:51:23 2007] [warn] NameVirtualHost *:0 has no VirtualHosts
[Wed Jan 17 00:51:23 2007] [warn] NameVirtualHost *:80 has no VirtualHosts

I'm used to seeing the ServerName error, but what's wrong with my virtual host setup?

Thanks for the help--I'm googled-out!

reddazz 01-17-2007 03:32 AM

Is the sections that enables virtual hosts uncommented. The section should be something like
Code:

# Virtual hosts
#Include etc/apache22/extra/httpd-vhosts.conf

The paths in the example may not be the same as the ones on your system because I copied those from my FreeBSD installation.

gregmcavoy 01-17-2007 08:41 AM

It looks like this:

Code:

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

But I haven't done anything with sites-enabled. I'm used to working with Apache 1.3, so if 2.2 requires me to do something there, I'll need pointers. From the Apache 2.2 documentation, it looks like it just gives me the option of creating a special conf file for each virtual host, which I don't think I need.

And actually, I'm getting this sometimes, too (when trying to use the virtual host code listed above):
Code:

# apache2ctl start
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Wed Jan 17 15:07:04 2007] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Wed Jan 17 15:07:04 2007] [warn] NameVirtualHost *:0 has no VirtualHosts
[Wed Jan 17 15:07:04 2007] [warn] NameVirtualHost *:80 has no VirtualHosts
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

But rebooting clears the darned sock error.

Any other ideas on getting the virtual hosts to be recognized normally?

gregmcavoy 01-17-2007 06:44 PM

Ok, this was just because I had no knowledge of how to use Apache 2.2.
http://www.linux.com/article.pl?sid=05/09/01/186204.

I needed to not have the virtual servers in httpd.conf, but instead have them in sites-available and then ln -s them to sites-enabled.

I got this set of error messages, however:

Code:

# apache2ctl start
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

But this was because I can't include "Listen 80". That's already taken care of in ports.conf. Finally, I changed the first line of the virtual host configuration files to <VirtualHost *>, and made sure I didn't have NameVirtualHost * on any virtual host except the default. Now it's fixed.


All times are GMT -5. The time now is 04:26 AM.