Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have multiple domain names registered. I want to host them using a single Apache server on a private virtual server. I know this is possible, by making changes in httpd.conf and (possibly /etc/hosts), but I can't find any information on how to actually do it.

Could anyone please explain the steps required in doing this?. Example, supposing I have the following names available:

  • example1.com
  • example2.com
  • example3.com

How may I setup the Apache server so that it serves pages from the above domains?

BTW, I am running Apache 2.2. on Ubuntu Linux (Lucid Lynx [10.04 LTS])

share|improve this question

migrated from superuser.com Jul 9 '10 at 14:33

This question came from our site for computer enthusiasts and power users.

2 Answers 2

This should help you: http://www.debian-administration.org/articles/412

share|improve this answer

Edit apache configuration => httpd.conf

Add this lines:

#if you are listening in the port 80, enable the virtual host
NameVirtualHost *:80

#DocumentRoot is the folder where the actual web site resides, where the html and php files are.
#Directory => this instruction is for setting the permissions, de directory index, etc.

 <VirtualHost *:80>
    ServerAdmin alex@example1.com

    DocumentRoot "C:/mywebsites/example1"
    ServerName example1.com
    ServerAlias www.example1.com

    <Directory "C:/mywebsites/example1">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all

 <VirtualHost *:80>
    ServerAdmin alex@example2.com
    DocumentRoot "C:/mywebsites/example2"
    ServerName example2.com
    ServerAlias www.example2.com

    <Directory "C:/mywebsites/example2">
        DirectoryIndex index.html
        AllowOverride All
        Order allow,deny
        Allow from all

 <VirtualHost *:80>
    ServerAdmin alex@example3.com
    DocumentRoot "C:/mywebsites/example3"
    ServerName example3.com
    ServerAlias www.example3.com

    <Directory "C:/mywebsites/example3">
        DirectoryIndex default.php
        AllowOverride All
        Order allow,deny
        Allow from all

As you probably realized, I´m running windows, but it's the same for unix. For more information read Apache configuration for the directives DocumentRoot, VirtualHost and Directory.

All this does is, if somebody ask the apache server for example2.com, Apache will serve the request from C:/mywebsites/example2 using as index index.html. But apache needs to be asked (be polite...) What I mean is, you have to change your dns to point this web sites to the NIC IP Address apache is listening.

In my computer, Windows, I use the host file, like this:


Because I had set this directive in httpd.conf

Listen  80



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.