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 and in DNS, and a subinterface of hme0:1 be and 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 --> /index.html --> /directory/index.html
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.

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

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

    ServerName # This is the DNS name you want to associate
    DocumentRoot /baz/httpd

        # some directory stuff here that applies to this virtual host.
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?

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)

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.