apache tutorial - What is Virtual host in Apache - apache - apache web server - apache server - apache2

Virtual host in apache

  • An Apache web server can host multiple websites on the SAME server. You do not need separate server machine and apache software for each website. This can achieved using the concept of Virtual Host or VHost.
  • Any domain that you want to host on your web server will have a separate entry in apache configuration file.

Types of Apache Virtualhost

  • Name-based Virtual host
  • Address-based or IP based virtual host and.

Name-based Virtual Host

  • Name based virtual hosting is used to host multiple virtual sites on a single IP address.
  • n order to configure name based virtual hosting, you have to set the IP address on which you are going to receive the Apache requests for all the desired websites. You can do this by NameVirutalHost directive within the apache configuration i.e. httpd.conf/apache2.conf file.

Apache virtual host Example:

NameVirtualHost *:80


ServerAdmin [email protected]

DocumentRoot /var/www/html/example1.com      

ServerName www.example1.com



ServerAdmin admin[email protected]

DocumentRoot /var/www/html/example2.com

ServerName www.example2.com

click below button to copy the code. By Apache tutorial team
  • You can add as many virtual hosts, as per your requirement. You can check your web configuration files with:
[[email protected] ~]#httpd –t
Syntax OK
click below button to copy the code. By Apache tutorial team
  • f the configuration file has some wrong syntax, it will throw an error
[[email protected] conf.d]# httpd -t

Syntax error on line 978 of /etc/httpd/conf/httpd.conf:

Invalid command '*', perhaps misspelled or defined by a module not included in the server configuration
click below button to copy the code. By Apache tutorial team

Related Searches to what is virtual host in apache

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.