Apache is a powerful and flexible HTTP/1.1 compliant web server. Originally designed as a replacement for the NCSA HTTP Server, it has grown to be the most popular web server on the Internet. As a project of the Apache Software Foundation, the developers aim to collaboratively develop and maintain a robust, commercial-grade, standards-based server with freely available source code.

The Apache HTTP Server is distributed at no charge for commercial or non-commercial use. For more information read the LICENSE.txt file.

Apache can be used with Microsoft Windows. The Apache HTTP Server Version 2.0 runs under Windows NT, Windows 2000 and Windows XP. You should download the version of Apache for Windows with the .msi extension. This is a single Microsoft Installer file containing Apache, ready to install and run.

The latest Apache HTTP Server version can be downloaded from: http://httpd.apache.org/
The latest Apache 1.3 documentation can be found at: http://httpd.apache.org/docs/1.3/
The latest Apache 2.0 documentation can be found at: http://httpd.apache.org/docs/2.0/
The latest Apache 2.2 documentation can be found at: http://httpd.apache.org/docs/2.2/

Apache 2.2.11: Host two domains using name-based virtual hosting.


Operating system used
Windows Vista Home Premium SP 1

Software prerequisites
Apache 2.2.11

  1. Lets assume you have two domain names and one ip address, e.g.:

    IP URL http://www.mobilefish.com http://www.abcxyz.com

    and you want to host both domains on the same web server by using name-based virtual hosting.

    To serve your webpages by Apache, first create two DocumentRoots from which you will serve your web pages. As an example, create the following directories:

    • c:\mobilefish_web (for www.mobilefish.com)
    • c:\abcxyz_web (for www.abcxyz.com)

    and put all your webpages in their respective directories.

  2. Add and change the following lines in the
    C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf file, e.g.:

    Uncomment the following lines:

    ServerName www.mobilefish.com:80

    LoadModule rewrite_module modules/mod_rewrite.so
    LoadModule userdir_module modules/mod_userdir.so
    LoadModule vhost_alias_module modules/mod_vhost_alias.so

    AddType text/html .shtm
    AddOutputFilter INCLUDES .shtm

    Include conf/extra/httpd-userdir.conf

    Include conf/extra/httpd-vhosts.conf

    Change the following line:

    DirectoryIndex index.html index.shtm index.htm

    View the updated httpd.conf file.

  3. Comment out all lines in
    C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-userdir.conf file and add the following lines, e.g.:

    <Directory "c:/mobilefish_web">
       Options Indexes FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all

       Options +Includes
       AddType text/html shtm
       AddOutputFilter Includes shtm
       AllowOverride All

    <Directory "c:/abcxyz_web">
       Options Indexes FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all

       Options +Includes
       AddType text/html shtm
       AddOutputFilter Includes shtm
       AllowOverride All

    View the updated httpd-userdir.conf file.

  4. Add the following lines in the
    C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf file, e.g.:

    <VirtualHost *:80>
       ServerAdmin [email protected]
       DocumentRoot "C:/mobilefish_web"
       ServerName www.mobilefish.com
       ErrorLog "logs/www.mobilefish.com-error.log"
       CustomLog "logs/www.mobilefish.com-access.log" common

    <VirtualHost *:80>
       ServerAdmin [email protected]
       DocumentRoot "C:/abcxyz_web"
       ServerName www.abcxyz.com
       ErrorLog "logs/www.abcxyz.com-error.log"
       CustomLog "logs/www.abcxyz.com-access.log" common

    View the updated httpd-vhosts.conf.conf file.

  5. Run syntax check for all config files:

    c:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd -t

    You should see the following:

    Syntax OK

  6. If the config files are all correctly modified, always restart Apache.

  7. If you do not have a DNS server, you can modify file:
    Add the following lines:     www.mobilefish.com     www.abcxyz.com

  8. Now you can access both websites by their domainname, i.e.: