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
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. ;)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.