Small Cheese

How To Run Multiple Domains With Apache Web Server

As with other standard web server applications, Apache is capable of hosting multiple domain names in single computer hardware.

Simply put, you can have multiple domain names pointed or resolved to one IP address and each of these domain names is bound to different home page.

I’ve tried this simple Apache tutorial with Apache 2 (httpd-2.0.52-9.ent) running on Red Hat Enterprise Linux 4 Update 4 (IP
  1. Edit Apache setting file, i.e.
    vi /etc/httpd/conf/httpd.conf
  2. Suppose that the Apache is not already configured to support virtual host, the NameVirtualHost and VirtualHost directives are both commented. Confirm this is true.
  3. Append these sample of setting lines to the bottom of httpd.conf file
            DocumentRoot /var/www/html/smallcheese_net
            DocumentRoot /var/www/html/testing_com

    To get Apache serve more domain name, simple duplicate the block of <VirtualHost></VirtualHost>, where
    • DocumentRoot refers to directory that keep webpages of the specific domain.
    • ServerName is the domain name that served by Apache web server.
  4. Edit the DNS or local host file (e.g. vi /etc/hosts) to map and to Apache web server IP address (i.e. For Windows client (e.g. Windows XP or Windows Vista) the local hosts file can be located at %windir%\System32\drivers\etc\ directory.
  5. Restart the Apache web server (httpd) to make changes effective.
    service httpd restart
  6. Open web browser and browse to those domain name. Make sure the DocumentRoot directory is already containing the web pages (at least with index.html or the home page file)

Other than the DocumentRoot and ServerName, you can also specify error log file, etc. For more VirtualHost related setting, consult the httpd.conf manual page.

Custom Search