I just bought a Linode VPS hosting plan and was following this guide to set up. In the "Setting the Hostname" section and "Update /etc/hosts " section, it says the FQDN/hostname to be set here does not need to be related with the websites I am about to host, which makes me confused.
I did my own research by reading lots of articles but am still not very sure what role the hostname/FQDN is playing in my web hosting business. Here are some basic facts I've managed to find out, feel free to correct me if anything wrong:
- FQDN must be something like xxx.somedomain.com, if "xxx." is omitted then it is not a FQDN.
- the
xxx
, which I think could be loosely called a subdomain, can also be referred to as "hostname", according to https://kb.iu.edu/d/aiuv. In my local machine, by adding the following line to the
hosts
file63.117.14.58 www.yahoo.com whatever
every network requests for "www.yahoo.com" or "whatever" will be redirected to IP address 63.117.14.58(which is google.com's IP). It is a way to block unwanted sites in local machine.
Now the tutorial suggests adding this line to the "hosts" file in my server
12.34.56.78(//my server's IP) myhostname.anything.com myhostname
It mentions that in the above line, domain name may or may not be the domain I am about to host, but the hostname should be the one I have already set during previous steps. My questions are:
1)Based on Facts#3, I think this line redirects any requests on the server for myhostname.anything.com
or myhostname
to my IP address, but what does this mean? Shouldn't any request for myhostname.anything.com
from a user's computer already be translated to a certain IP address(Be it or not my IP address)? Why do I have to redirect it on my server? My understanding about how a HTTP request works is when user type in the domain name into the browser, the browser will contact the domain server, and the domain server will direct it to a DNS server based on the domain's DNS record, and then the DNS server will resolve the IP address, and then browser fetch data from that IP address. This procedure of my understanding seems having nothing to do with the "hosts" file on my server.
2) A.In regards of the FQDN, why the hostname has to be same with the hostname I set on my server and the domain name doesn't?
B.What will happen if I do set a different hostname here?
C.And what is the purpose to set or not set my domain name as the FQDN here?
D.And what will happen if I only set a FQDN but not the hostname? like this
12.34.56.78(//my server's IP) myhostname.anything.com
Lots of questions but I believe the answers to some of them are overlapped, and overall I think the big question is "What part does setting hostname/editting hosts file play in my webhosting business?"
Thank you for your time in advance.