2

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
    ...
</VirtualHost>

Also, I updated my /etc/hosts file as follows:

127.0.0.1    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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.