Creating sub-domain in Apache

HTTP Apache

Steps to create sub-domain on Apache :

1). Uncomment “Include conf/extra/httpd-vhosts.conf” line in the httpd.conf file.

2).Open the httpd-vhosts.conf file and enter the below mentioned line-


    ServerName mydomain.xyz.com
    DocumentRoot "/var/www/html/mydomain"

Note : 10.10.10.10 is the ip address of the server, provide the sub-domain name against the “ServerName” field and if there is any particular index.html file for this sub-domain, than give the path of that index.html against the “DocumentRoot”.

3).Now open the hosts file in your local machine and enter the below mentioned line –

10.10.10.10 mydomain.xyz.com

Now when you will hit the http://mydomain.xyz.com/ the hosts file will resolve this url internally to the ip address provided in the hosts file and the index.html page that we have given for this sub-domain page will open.