Tuesday, June 5, 2012

Virtual Host: multiple domain names on a machine Part I

PIN code is an address identifier to your location , Similarly an IP address , is an address that identifies a machine , Most of the interaction of a user to any machine is based on IP address.

Domain name service lets you map a Domain Name with an IP address , which means one can use a simple to remember a domain name and not remember the IP address. A server is usually a costly resource so what a hosting company simply does is hosts multiple domains on one machine. This way they can simply give a slice of hard disk space of a machine to a single user. This way an expensive resource can be utilize to maximize profits.

Lets see how you can do it , with Apache Virtual host configuration. This is not a post on automatic virtual configurations.

There are two ways of doing this one is the hard way:
  1. Create a new file in folder 
    1. /etc/apache2/sites-enabled
    2. Paste in following code 
    3. <VirtualHost *:80>
        DocumentRoot /home/shyam/workone/
          ServerName workedhost
            <Directory "/home/shyam/workone/">
              allow from all
                Options +Indexes
                  </Directory>
                    </VirtualHost>

                  1. at this point simply do
                    sudo a2ensite nameofthefile or
                    simply do a symlink of this file in site-enabled folder in /etc/apache2
                    works in ubuntu this way
                  2. Lets analyse this perticular code 
                The first line virtualhost directive  with * which signifies the address on which this domain name will be processed , In this case its any address associated with the servers ip address

                Now the next thing is :80 , his signifiies the port on which the hosting is going to be done 


                After this you have a directive called the DocumentRoot

                This directive shows where the server files are going to be stored
                Now lets look at the directory directive :

                With this we have attribute thats showing a path to DocumentRoot directory , This is done so we could apply some rules to this directory ,
                Current rules are

                apply from all , this allows all host names to access this files
                Options +Indexes Means it will look for default index file in the perticular directory


                Now you are ready to have a virtual host in ubuntu


                In case of any other OS , you could try putting this in Apache.conf(windows) or httpd.conf(fedora) file

                Of you could simply write this in a file and load it  with
                 Include "relative or absolute path to file"


                This in the first , or what i call manual case , Lets cover how to do it easy using a tool called webmin , Make sure you keep and Eye out for that post , You will see lots of things that can be done easily with out any hassle

                5 comments:

                1. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! שרת וירטואלי

                  ReplyDelete
                2. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. nemzetköziáruszállításEuropa-Road Kft

                  ReplyDelete
                3. Cool stuff you have got and you keep update all of us. onohosting

                  ReplyDelete
                4. This content is written very well. Your use of formatting when making your points makes your observations very clear and easy to understand. Thank you. Domain kaufen

                  ReplyDelete