4. Hosting Multiple Web Sites

One of the most popular options is Apache is virtual hosting. Virtual hosting with Apache allows a single machine to serve multiple websites called Virtual Hosts. Each different site can have its own unique configuration, or just use the default settings. There are two comon methods for Virtual Hosting.

Most Virtual Hosting is done using the name based method. This tutorial will create two name based virtual hosts.

4.1. Graphically

Within Gnome or KDE, do the following:

  • pants

4.2. On the command line

Open a terminal and do the following:

  • Add entries for each name to DNS. Create entries pointing each addresses to the IP address of your web server.

  • Create directories for each web site. mkdir -p /var/www/site1.stationx.example.com mkdir -p /var/www/site2.stationx.example.com

  • Create content in each directory. cp -rv /training/misc/site1/* /var/www/site1.stationx.example.com cp -rv /training/misc/site2/* /var/www/site2.stationx.example.com

  • Set up Apache for name based virtual hosting. In httpd.conf NameVirtualHost 192.168.5.x

  • Set up each virtualhost in configuration files: You could add the lines below to the bottom of httpd.conf, but creating two new files under conf.d for each website is a little neater. In /etc/httpd/conf.d/

    
    
    
     
    

     
    
     
    

  • Visit your partners virtual host at http://site1.stationy.example.com