?
Solved

hosting multiple sites on same host with apache on specific IP

Posted on 2011-10-20
4
Medium Priority
?
221 Views
Last Modified: 2012-05-12
I have a host with 5 IP addresses and I'd like to use 4 of them for various sites, but I would also like to choose which site is on which IP address and have multiple sites on same IP.

I got a warning with what I attempted below - What is the correct way of doing this?
<VirtualHost [IP ADDRESS 2]:80>
        ServerName www.domain.com
        ServerAlias www.domain.com domain.com
        DocumentRoot /www/domain/
        DirectoryIndex index.php index.html index.htm
</VirtualHost>

<VirtualHost [IP ADDRESS 2]:80>
        ServerName www.domain2.com
        ServerAlias www.domain2.com domain2.com
        DocumentRoot /www/domain2/
        DirectoryIndex index.php index.html index.htm
</VirtualHost>

[warn] VirtualHost IP ADDRESS 2:80 overlaps with VirtualHost IP ADDRESS 2:80, the first has precedence, perhaps you need a NameVirtualHost directive
[  OK  ]

Open in new window

0
Comment
Question by:ee-gd
  • 2
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 2000 total points
ID: 36999904
> [warn] VirtualHost IP ADDRESS 2:80 overlaps with VirtualHost IP ADDRESS 2:80, the first has precedence, perhaps you need a NameVirtualHost directive

Add to your config file "NameVirtualHost IP_ADDRESS_2:80" (without "") before your VirtualHost definitions.
0
 

Author Comment

by:ee-gd
ID: 36999993
thanks oklit

so in the config file I should have something like this whereby I can have multiple NameVirtualHost directives?

NameVirtualHost IP_ADDRESS_2:80
<VirtualHost [IP ADDRESS 2]:80></VirtualHost>
<VirtualHost [IP ADDRESS 2]:80></VirtualHost>

NameVirtualHost IP_ADDRESS_3:80
<VirtualHost [IP ADDRESS 3]:80></VirtualHost>
<VirtualHost [IP ADDRESS 3]:80></VirtualHost>
0
 

Author Comment

by:ee-gd
ID: 37000059
in the context of the named virtual host what would the default server pickup? port 80 requests with no domain name?
apachectl configtest
Syntax OK

httpd -S
VirtualHost configuration:
IP ADDRESS 2:80      is a NameVirtualHost
         default server www.domain.com (/etc/httpd/conf/httpd.include:22)
         port 80 namevhost www.domain.com (/etc/httpd/conf/httpd.include:22)
         port 80 namevhost www.domain2.com (/etc/httpd/conf/httpd.include:30)
IP ADDRESS 3:80      is a NameVirtualHost
         default server www.domain3.com (/etc/httpd/conf/httpd.include:3)
         port 80 namevhost www.domain3.com (/etc/httpd/conf/httpd.include:3)
         port 80 namevhost www.domain4.com (/etc/httpd/conf/httpd.include:11)
wildcard NameVirtualHosts and _default_ servers:
_default_:8443         localhost.localdomain (/etc/httpd/conf.d/nss.conf:84)
_default_:443          localhost.localdomain (/etc/httpd/conf.d/ssl.conf:81)
Syntax OK

Open in new window

0
 
LVL 23

Expert Comment

by:Maciej S
ID: 37002513
I'm not sure if I understand your question.
If you enter your ip address 2 in web browser, you will get www.domain.com page.
If you enter your ip address 3 in web browser, you will get www.domain3.com page.

Is that what you are asking for?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question