Contact for queries :


  UpComing Live WebEx Workshop Series

Configuring Apache Virtual Hosts in Linux

One of the big benefits of Apache is that you can run multiple websites on a single host. This is done through a virtual host configuration, where you can define different sites in your main Apache config file. We have already discussed the global options and main server options in the main config file. The third section deals
with virtual host options:
NameVirtualHost Specifies the hostname or IP address for the virtual host

  • ServerAdmin Indicates the email address for the webmaster
  • DocumentRoot Defines the directory for the virtual host files
  • ServerName Defines the URL for the virtual host
  • ErrorLog Specifies the location for the error log
  • CustomLog Specifies the location for a custom log

Many of these options are similar to options provided in the main server section of the config file. If an option is not defined in the virtual host section, it defaults to whatever is set in the main server section.
Setting up virtual hosts is easy; just do the following:
Step 1. Copy the main server section default site as an example:

<VirtualHost *:80>
DocumentRoot /var/www/site1
ErrorLog logs/site1_error_log
CustomLog logs/site1_access_log common

Step 2. Don’t forget to verify the syntax before running with the config:

# httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
Syntax OK

Step 3. If you have multiple virtual host sites, you can check them with the following:

# httpd -D DUMP_VHOSTS
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
Syntax OK

November 14, 2015

0 responses on "Configuring Apache Virtual Hosts in Linux"

Leave a Message

Your email address will not be published. Required fields are marked *


IGURKUL I.T. Training Hub offering various Career Certification courses in Computer Networking, Unix, Linux, Cloud Computing and DevOps Technologies. With its rich experience in IT training service sector, iGURKUL has been able to set Industry best practices in IT Training for the past five years.

In Past five years, more than 5000 professionals have been trained by iGURKUL for System administration, Cloud Computing and DevOps Skill set through our Online Training portal And , each day , more than 10000 working professionals from all over the globe visiting our knowledge base for the best practices and Knowledge learning.

copyright protected - 2011 © igurkul I.T. solutions. All rights reserved.