Multiple interfaces required to run multiple Apache web servers?

Posted on 2004-11-29
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 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
Question by:shanepresley
    LVL 13

    Expert Comment

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

    Expert Comment

    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.
    LVL 1

    Author Comment

    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

    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)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    PHP clean up nicely even if user abort 13 34
    XAMPP / PHPmyadmin 5 58
    RewrteRule using htacess 10 46
    file path 14 57
    In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting ( to http…
    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now