Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 6th June 2010, 18:57
terbor terbor is offline
Junior Member
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apache Multiple Domains + subdomains

Hi I am running into an issue with apache and setting up multiple domains on one server.

Apache/2.2.12 (Ubuntu) Server 9.10
bind9

Issue:
All traffic funnels to the first Virtual Host

Setup:
Bind:
I setup 3 master zones asub.domain.com, domain.com, url.com (All traffic from these 3 are going to asub.domain.com, but if I delete asub the traffic will then go to domain.com)

Apache:

In sites-enabled
domain.conf
Code:
 <VirtualHost *>
   DocumentRoot /home/domain/asub
       ServerName asub.domain.com
       ServerAlias  www.asub.domain.com
       <Directory "/home/domain/asub">
       allow from all
       Options +Indexes
       </Directory>
 </VirtualHost>
<VirtualHost *>
DocumentRoot /home/domain/www
    ServerName domain.com
    ServerAlias  www.domain.com
     <Directory "/home/domain/www">
     allow from all
    Options +Indexes
    </Directory>
</VirtualHost>
url.conf
Code:
<VirtualHost *>
DocumentRoot /home/url/www
    ServerName url.com
    ServerAlias  www.url.com
     <Directory "/home/url/www">
     allow from all
    Options +Indexes
    </Directory>
</VirtualHost>
Thank you for any help
Reply With Quote
Sponsored Links
  #2  
Old 7th June 2010, 02:52
matty matty is offline
Member
 
Join Date: Apr 2010
Location: Australia
Posts: 85
Thanks: 2
Thanked 12 Times in 11 Posts
Default

I'm a bit rusty on my Apache, but I'm pretty sure you need to name your VirtualHost, and put the wildcard/default entry last.

ie.

Code:
<VirtualHost asub.domain.com>
   DocumentRoot /home/domain/asub
       ServerName asub.domain.com
       ServerAlias  www.asub.domain.com
       <Directory "/home/domain/asub">
       allow from all
       Options +Indexes
       </Directory>
 </VirtualHost>
<VirtualHost domain.com>
DocumentRoot /home/domain/www
    ServerName domain.com
    ServerAlias  www.domain.com
     <Directory "/home/domain/www">
     allow from all
    Options +Indexes
    </Directory>
</VirtualHost>
<VirtualHost *.domain.com>
DocumentRoot /home/domain/www
    ServerName *.domain.com
     <Directory "/home/domain/www/promos">
     allow from all
    Options +Indexes
    </Directory>
</VirtualHost>
kind of thing. Apache reads the conf from top to bottom, so will match at the first chance, which the wild card does when it's at the top of the file.
Reply With Quote
  #3  
Old 7th June 2010, 17:07
terbor terbor is offline
Junior Member
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply, but I get an error when trying that ... I did see another post in here where the person used the * as I did here and it seemed to work for them ...

Quote:
* Restarting web server apache2
[Mon Jun 07 11:03:36 2010] [error] (EAI 2)Name or service not known: Could not resolve host name *.domain.com -- ignoring!
[Mon Jun 07 11:03:36 2010] [warn] VirtualHost modirac.com:80 overlaps with VirtualHost asub.domain.com:80, the first has precedence, perhaps you need a NameVirtualHost directive
... waiting [Mon Jun 07 11:03:58 2010] [error] (EAI 2)Name or service not known: Could not resolve host name *.domain.com -- ignoring!
[Mon Jun 07 11:03:58 2010] [warn] VirtualHost domain.com:80 overlaps with VirtualHost asub.domain.com:80, the first has precedence, perhaps you need a NameVirtualHost directive
Reply With Quote
  #4  
Old 8th June 2010, 00:34
matty matty is offline
Member
 
Join Date: Apr 2010
Location: Australia
Posts: 85
Thanks: 2
Thanked 12 Times in 11 Posts
Default

Sorry, brain fart on my part. Getting old isn't much fun sometimes..

I got my VirtualHost and NameVirtualHost bass-ackwards.

Check you have an entry for NameVirtualHost, and that the server can resolve your DNS entries for your websites.

What I should have done in the first place is refer you to the actual documentation.

http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Reply With Quote
  #5  
Old 8th June 2010, 04:33
terbor terbor is offline
Junior Member
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Thanks again for your help, I have been going back and forth between my old server and new server since I didnt move everything over yet I was changing where I was pointing the namservers for the same hostname and then apache would no longer honor the name setup that I had on the new server ... It works the way it should now ...
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to install roundcubemail ressel Installation/Configuration 13 24th December 2009 20:13
Exim Gateway with mailwatch (Unable to receive emails) siul0_0 HOWTO-Related Questions 10 8th May 2009 23:00
problems with suexec gobokster Installation/Configuration 7 7th May 2009 13:33
CENTOS 5 Ping Problem gAnDo Server Operation 11 28th March 2008 20:58
Problem with the installation of Dokeos (LMS) in ISPConfig jofranco General 4 28th April 2006 00:45


All times are GMT +2. The time now is 06:07.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.