Search

Create multiple virtual host in apache

  • Share this:
post-title

It is very simple to create many virtualhost in apache. As following example

<VirtualHost *:80>
    ServerName hr.example.com
    ServerAlias hr.example.com
    ServerAdmin admin@example.com
    DocumentRoot /home/hr/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined    
    
</VirtualHost>

<VirtualHost *:80>
    ServerName inventory.example.com
    ServerAlias inventory.example.com
    ServerAdmin admin@example.com
    DocumentRoot /home/inventory/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined    
   
</VirtualHost>
<VirtualHost *:80>
    ServerName hrd.example.com
    ServerAlias hrd.example.com
    ServerAdmin admin@example.com
    DocumentRoot /home/hrd/public_html/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined    
   
</VirtualHost>

and filnally restart apache.

Yusuf Khalil

Yusuf Khalil