Jump to content

Correct setup of Apache, etc/hosts and DNS on Ubuntu server


UbuntuJon

Recommended Posts

Hi

 

Just wanted some advice on the above. I'm trying to configure a cloud server (Ubuntu), and had a couple of questions.

 

1) My etc/hosts file, apache vhost and DNS all contain my domain name as domain.tld (without the www). In my vhost I have server name as domain.tld, and two server aliases set as www.domain.tld and *.domain.tld - I can reach my site with the URL "domain.tld", but not with "www.domain.tld". Does this mean I need two DNS records setup, one for "domain.tld" and one for "www.domain.tld"? Surely not? I thought that was the point of ServerAlias?

 

2) Am I supposed to add my domain name to my server's etc/hosts file? Or is that something I don't need to be doing?

 

Thanks all

 

Jon

Link to comment
Share on other sites

ServerAlias only means that apache will recognize that server name as also belonging to the given vhost. You still need a DNS entry so that clients can resolve that domain to the proper IP address. You can do this either with a separate A entry or a CNAME record.

 

Adding the domain to the hosts file is not strictly necessary so long as it exists in DNS.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.