0

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 :

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

3 Answers3

2

Okay, DNS:

Open /etc/hosts, add lines like this:

127.0.0.1               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


</VirtualHost>

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

Aquarion
  • 275
  • 1
  • 4
  • 10
0

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

brianegge
  • 1,064
  • 2
  • 14
  • 23
0

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.