Multiple interfaces required to run multiple Apache web servers?

Posted on 2004-11-29
Medium Priority
Last Modified: 2010-03-04
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 web.domain.com in DNS, and a subinterface of hme0:1 be 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
Question by:shanepresley
  • 3
LVL 13

Expert Comment

ID: 12699572
Yes, this is called Virtual Hosting... Hold on a minute and I'll point you to the doc.
LVL 13

Expert Comment

ID: 12699610
Here's the document:


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

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

        # some directory stuff here that applies to this virtual host.

Author Comment

ID: 12699623
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?

LVL 13

Accepted Solution

gripe earned 2000 total points
ID: 12699806
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)

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

807 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