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
LVL 1
shanepresleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gripeCommented:
Yes, this is called Virtual Hosting... Hold on a minute and I'll point you to the doc.
0
gripeCommented:
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>
0
shanepresleyAuthor Commented:
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?

0
gripeCommented:
The pros are that you can re-use a single IP over and over again for many sites as opposed to dedicating an entire IP and port pair to one.

There aren't many cons. You will no longer be able to access your vhosts by IP (since they no longer have a unique IP and the 'Host:' header is used to access the correct site) but this isn't generally a big deal. I had some issues with redirection many moons ago but I don't remember the specifics and I remember it being easy to fix.

Another con is that all sites that are vhosted under a single instance of apache are affected by apache restarts and/or problems.

For most sites Virtual hosting is perfect. A lot of people are vhosted by their webhosting company without even knowing it. (It's that transparent)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.