Link to home
Start Free TrialLog in
Avatar of shanepresley
shanepresley

asked on

Multiple interfaces required to run multiple Apache web servers?

I've noticed that some webservers have sub-interfaces with different IPs, so that they can serve up different web sites.

For example, a single box running Solaris 8 might have it's primary interface (hme0) be 10.1.1.10 and web.domain.com in DNS, and a subinterface of hme0:1 be 10.1.1.11 and web2.domain.com in DNS.

They do that so that when you browse to http://web or http://web2 you get different sites, but both served by Apache on the same box..

Isn't it possible in Apache to use a single IP, and direct to different websites based on the DNS name someone uses?

For example Apache would say  

http://web.domain.com --> /index.html
http://web2.domain.com --> /directory/index.html
Avatar of gripe
gripe

Yes, this is called Virtual Hosting... Hold on a minute and I'll point you to the doc.
Here's the document:

http://httpd.apache.org/docs/vhosts/

It's very easy to set up. For instance, here's an example:

<VirtualHost 123.123.123.123>
    ServerName foo.bar.com # This is the DNS name you want to associate
    DocumentRoot /baz/httpd

    <Directory>
        # some directory stuff here that applies to this virtual host.
    </Directory>
</VirtualHost>
Avatar of shanepresley

ASKER

Thanks.  I'd also appreciate any pros/cons of doing it with one IP vs multiple IPs, assuming you are running on the same physical box?

ASKER CERTIFIED SOLUTION
Avatar of gripe
gripe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial