Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i m using ubuntu & wants to Create Subdomain on Virtual Host for local host.

i have already created server name on my local host but now wants to Create Subdomains on Virtual Host for local host.

like my server name is sajid.msj then i wants my subdomain must be like :

share|improve this question

migrated from stackoverflow.com Nov 18 '09 at 12:42

This question came from our site for professional and enthusiast programmers.

"must be like :" ? I think you're missing the end of the sentence, and probably a lot more infos before we can answer this. –  ℝaphink Dec 26 '09 at 10:04

3 Answers 3

Okay, DNS:

Open /etc/hosts, add lines like this:               localhost sajid.msj subdomain.sajid.msj anothersubdomain.sajid.msj

If you want this to be available to other machines on the network, you'll need to use the intranet IP

The way I do mass hosting of subdomains is with mod_vhost_alias, like this:

sudo a2enmod vhost_alias

and then a file in /etc/apache2/sites-enabled called 000vhosting which contains:

<VirtualHost *:80>

DocumentRoot /home/nicholas/Sites/

ServerName *
# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
# LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{User-agent}i\"" vcommon

#RewriteLog /tmp/rewrite.log
#RewriteLogLevel 9

CustomLog /var/log/apache2/vhost_access.log vcommon

# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /home/nicholas/Sites/%0/public_html
VirtualScriptAlias /home/nicholas/Sites/%0/cgi-bin


Then for every subdomain, you create a directory in wherever you put your Sites directory with the same name, and then the root of the site will point to a directory called public_html within that.

So subdomain.sajid.msj is contained in /home/nicholas/Sites/subdomain.sajid.msj/public_html

share|improve this answer
Dude, that vhost file is badass. Now I've got a project for my server over the week to implement this. –  David Rickman Dec 26 '09 at 20:22

Are you wanting to know about DNS configuration or web server config? If web server, which one - Apache?

share|improve this answer
well i m new to this. but may be u suppose right.. –  muhammad Sajid Nov 18 '09 at 11:24
dude you need to include a LOT more information before we can help –  Chopper3 Nov 18 '09 at 12:47

Muhammad, the following documentation might interest you (if you care to know how Aquarion generated the configuration to your server):

Hosts File: http://en.wikipedia.org/wiki/Hosts_file

And, if you want to know more about the server's internals, check out Apache 2.2 vHosts documentation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.