Walker News

How To Setup Multiple Virtual Hosts In Apache

In order to maximize resource utilization, one physical server hardware is usually configured to support multiple instances at one time.

In the case of web server, it’s not uncommon that most web hosting service providers are serving multiple domains in one super Linux machine. Statistically, majority of these Linux boxes are running Apache (the most popular web server)!
How To configure Apache virtual host feature to support multiple domains in one physical Linux hardware?
  1. Edit the Apache server configuration file, i.e.
    vi /etc/httpd/conf/httpd.conf
  2. Locate the NameVirtualHost and <VirtualHost> directives. By default, these directives are remarked or commented during installation.
  3. Suppose that the NameVirtualHost and <VirtualHost> directives are commented (that is why you’re here), append the following block of codes at the bottom of httpd.conf file
            DocumentRoot /var/www/html/walkernewsdotnet
            ServerName www.walkernerws.net
            DocumentRoot /var/www/html/exampledotcom
            ServerName www.example.com

    • is the Linux server IP address
    • DocumentRoot is the directory that keep the domain web pages
    • ServerName is the domain name
  4. Now, restart the Apache web server to make changes become effective,
    service httpd restart
  5. Edit the DNS server to resolve both www.walkernews.net and www.example.com to one IP address, i.e. in this guide.
    Alternative, you can edit the /etc/hosts file to maintain the domain name to IP mapping information.

    For Windows Vista and alike, the hosts file can be located at
  6. Finally, open your favourite web browser and enter the URL address to browse either www.walkernews.net or www.example.com.

This guide is tested successfully on my Red Hat Enterprise Linux 4 and Apache version 2 (httpd-2.0.52-9.ent).

Custom Search

  1. aurorius 02-10-10@12:11

    Thanks for the easy explanation, helped me setting apache for my Zend Framework project

2018  •  Privacy Policy