I have a domain example.com and a server named web. The webserver is running Apache2. Currently the server responds to requests to web.example.com. However, I want it to respond to requests to example.com.

In order to get this to work, I added the ServerAlias line to my apache virtual hosts:

<VirtualHost *.80>
    ServerName web.example.com
    ServerAlias example.com

Also, I updated my /etc/hosts file as follows:    localhost
<public_ip>  web.example.com web example.com

Finally I changed my DNS settings:

Name    Type    Value
@       A       <public_ip>
web     CNAME   @

The thing that confuses me mosts is the /etc/hosts file.

My questions:

  1. What is the role of /etc/hosts for my server that has an apache server running on it? What happens when I ask for web.example.com or example.com?

  2. What are the correct settings for my situation?

  3. Are there any books available that explain concepts related to these questions well?

Many thanks.


You must log in to answer this question.

Browse other questions tagged .