LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 08-10-2004, 11:32 AM   #1
chrisfx
LQ Newbie
 
Registered: Aug 2004
Posts: 2

Rep: Reputation: 0
Apache VirtualHost, multiple domains and subdomains on one IP


Hi!

I'm having some problems to configure the httpd.conf with multiple domains and subdomains on one IP.
I'm able to run a single domain with its subdomains, but multiple domains with multiple subdomains always returns me the 1st website of the config file.
I've read the doc, but it always concern multiple hosts or subdomains, not the mixed case.

So, i'd like to run 2 internet domains (with their respectives subdomains):
- xxx.domain1.com (alias: domain1.com)
- sub1.domain1.com
- sub2.domain1.com
(no separated logs, everything logged under domain1.com)
and
- xxx.domain2.com (alias: domain2.com)
- foo.domain2.com
- bar.domain2.com
(no separated logs, everything logged under domain2.com)

and the primary will be a local domain:
- home
(own access and error logs)

Code:
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName xxx.domain1.com
  ServerAlias domain1.com
  DocumentRoot /home/htdocs/domain1.com/
  CustomLog /home/htdocs/domain1.com/logs/domain1.com_access.log combined
  ErrorLog /home/htdocs/domain1.com/logs/domain1.com_error.log
</VirtualHost>

<VirtualHost *:80>
  ServerName sub1.domain1.com
  DocumentRoot /home/htdocs/domain1.com/sub1/
</VirtualHost>

<VirtualHost *:80>
  ServerName sub2.domain1.com
  DocumentRoot /home/htdocs/domain1.com/sub2/
</VirtualHost>


<VirtualHost *:80>
  ServerName xxx.domain2.com
  ServerAlias domain2.com
  DocumentRoot /home/htdocs/domain2.com/
  CustomLog /home/htdocs/domain2.com/logs/domain2.com_access.log combined
  ErrorLog /home/htdocs/domain2.com/logs/domain2.com_error.log

</VirtualHost>

<VirtualHost *:80>
  ServerName foo.domain2.com
  DocumentRoot /home/htdocs/domain2.com/foo/
</VirtualHost>

<VirtualHost *:80>
  ServerName bar.domain2.com
  DocumentRoot /home/htdocs/domain2.com/bar/
</VirtualHost>
and for the local site:

Code:
Port 80

ServerName home
ServerAdmin contact@home
DocumentRoot /home/htdocs/home

So when I try to reach xxx.domain2.com it always displays me xxx.domain1.com

UseCanonicalName and HostnameLookups are Off


any ideas?
thanks!

chrisfx


PS: as I'm new here and cannot post URLs containing "www" yet, i replaced "www" to "xxx" but it doesn't matter, just an ethetic point :P

Last edited by chrisfx; 08-10-2004 at 12:20 PM.
 
Old 08-10-2004, 02:01 PM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Did you set the server IP for the ServerName directive ? also, dns resolve both www.domain2.com and www.domain1.com to your machine ?
 
Old 08-10-2004, 02:58 PM   #3
chrisfx
LQ Newbie
 
Registered: Aug 2004
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your quick reply,

Well, until today, I was running everything fine using only one domain name, domain1.com for example, without specifying any IP address somewhere in the config file.

Both domain1.com and domain2.com resolves to my public IP addr.

I'm behind a firewall (privave IP: 192.168.0.1), port 80 is routed to my machine (192.168.0.2).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
APACHE and Subdomains basketkase999 Linux - Software 18 05-21-2005 10:38 PM
Apache: hosting multiple domains fturcic Linux - Software 1 02-15-2005 05:39 PM
apache userdir subdomains kodon Linux - Networking 7 08-09-2004 07:16 PM
Apache and Subdomains, Help pzorn Linux - General 2 01-27-2004 07:00 PM
Networking questions : Setting up domains/vhosts/subdomains/IPs etc. Belize Linux - Networking 1 09-16-2003 03:39 AM


All times are GMT -5. The time now is 09:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration