Jump to content

Multiple Virtual Hosts


scottybwoy

Recommended Posts

Hi,

 

I'm trying to set up 2 Virtual hosts in apache2 on kubuntu 8.10.  I have all the conf files and the symlinks in sites-enabled set up but I get this error:

 

VirtualHost www.pu.com:0 overlaps with VirtualHost www.test.com:0, the first has precedence, perhaps you need a NameVirtualHost directive

 

Do I need to set up NamedVirtualHosts?

 

I tried changing <VirtualHost xx.com> to <NameVirtualHost *:80> for default / pu / test .conf files but it didn't like it.

 

Any ideas, at the mo all 3 urls point to pu.com dir.

Link to comment
https://forums.phpfreaks.com/topic/151807-multiple-virtual-hosts/
Share on other sites

Thanks Corbin,

 

That looks great, but I don't understand ;p

 

Where do I put :

 

# Ensure that Apache listens on port 80

Listen 80

 

# Listen for virtual host requests on all IP addresses

NameVirtualHost *:80

 

I tried in default.conf in sites available, and in apache2.conf but I get this error :

 

NameVirtualHost *:80 has no VirtualHosts

(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

 

Sorry for not getting it. ;)

 

You don't need a second Listen statement.

 

 

Example:

 

 

NameVirtualHost *:80

 

<VirtualHost *:80>

DocumentRoot /www/example1

ServerName www.example.com

 

# Other directives here

 

</VirtualHost>

 

<VirtualHost *:80>

DocumentRoot /www/example2

ServerName www.example.org

 

# Other directives here

 

</VirtualHost>

 

 

That's all there is to it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.