Apache
  Home arrow Apache arrow Page 2 - Configuring and Using Virtual Hosts in...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
APACHE

Configuring and Using Virtual Hosts in Apache
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 94
    2004-06-30

    Table of Contents:
  • Configuring and Using Virtual Hosts in Apache
  • Edit the Main Configuration File
  • Virtual Host
  • Find File System Called Hosts

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Configuring and Using Virtual Hosts in Apache - Edit the Main Configuration File
    (Page 2 of 4 )

    True to its cutting edge character, Apache HTTP server was one of the first servers to begin providing support for virtual hosts and fortunately, configuring them is relatively easy. The mod_vhost_alias Apache module comes as standard with both the compiler and pre-compiled distributions. So no matter how you installed the software, it should be present on your system. For the purpose of this article, I’m assuming that you have already configured Apache for running your main host.

    There is a little work to be done in Apache’s main configuration file httpd.conf. Open this file by either browsing to the directory Apache is installed in and opening httpd from within the conf directory or, on a Windows platform, by selecting Edit the Apache http.conf configuration file from the start menu.

    Scroll right down to the bottom of the file to section 3, the virtual hosts section. Everything that you need to do in Apache to get a virtual host up and running is done within this section. There is already a commented out virtual host configuration for reference; you can leave this example in place for referring to later or you can remove the hash symbols at the start of each line and adjust the example -- it’s really up to you.

    The virtual host directives take precedence over the main server configuration, so to make sure that requests to your main host are not confused with requests to your virtual host, you have to add the main host as the first virtual host. This will ensure your main host stays as the default host. For the following example, I’ve used a main server name of site1.co.uk and I’m adding a virtual host called site2.co.uk, highly imaginative I know but it serves (no pun intended) to illustrate the point. As it’s simpler, we’ll look at name based virtual host configuration first.  

    More Apache Articles
    More By Dan Wellman


     

       

    APACHE ARTICLES

    - Putting Apache in Jail
    - Containing Intrusions in Apache
    - Server Limits for Apache Security
    - Setting Permissions in Apache
    - Installing Apache
    - Apache Installation and Configuration
    - Apache Tapestry and Custom Components: DateI...
    - Tapestry and AJAX: Autocompleter and InlineE...
    - PropertySelection and IPropertySelectionMode...
    - The DatePicker and Shell Components of Apach...
    - Apache Tapestry: ASO and More Components
    - Apache Tapestry and DirectLink, IoC and DI
    - Making a CelebrityCollector with Apache Tape...
    - Apache Tapestry and Listener Methods, Condit...
    - The Properties of Tapestry Pages

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway