4
votes

I have a dedicated server and a mydomain.com (bought from a hosting company). I want to host a website from my dedicated server with the domain mydomain.com i.e. when I enter mydomain.com from browser it should point to the IP(let's say X.X.X.X) of dedicated server(and a particular folder inside it). I have some following queries:

In Server

  1. I know I need to edit some of the files (like: host or hostname file) in the server but I do not know what exact file I need to edit.
  2. How to add a Site enable or Site available in apache2 ?

In Hosting Company control Panel

  1. Which records to add (A or cname or anyother)?
  2. Where Should I add DNS(in dedicated server section or domain name section)?
  3. How it is going to affect the behaviour of the domain?

in short the question is: How the virtual host works & how to add DNS? .

1

1 Answers

2
votes

For the server, you need to edit the httpd.conf file and add a VirtualHost entry, see here: http://httpd.apache.org/docs/2.2/vhosts/examples.html for some examples. Apache has good documentation, read it.

How does it work? Because you connect to the Apache server on an IP-address, the apache server does not know which domain you used to connect to, unless you tell it to it. In the HTTP/1.1 protocol, there is a header 'Host' that tells the server which domain was used to connect. Apache will then look the hostname up in its configuration files and server the right page.

In the DNS, you can decide your own policy. You could for example make an A record for each host and CNAMEs for all the subdomains.

There is a lot of information to be found on this subject on the internet. Google is your friend.

Good luck!