Apache
  Home arrow Apache arrow Page 2 - Configuring and Using Virtual Hosts in Apache
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
APACHE

Configuring and Using Virtual Hosts in Apache
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 101
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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

    - Creating a VAMP (Vista, Apache, MySQL, PHP) ...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek