Setup Nameserver for an Apache Webserver

9,923

Configuring DNS :

I have no idea of how to do that through godaddy's interface but here is what you need :

You have delegated the hosting of your DNS zone "example.com" to GoDaddy. So they are the one managing what's in the zone.

Now, for your server to be callable by its name, you have to make GoDaddy add a "A Record" to your zone, mapping www.example.comto your IP (say 12.13.14.15). You may want to consult wikipedia about how the DNS protocol really works.

Once your DNS zone is set, it's also better to modify your server-side configuration :

Set your server name in /etc/hosts :

127.0.0.1 localhost localhost.localdomain 12.13.14.15 www www.example.com

This will allow your host to resolve itself quicker than if it has to make a DNS query...

Modify your system name :

(if the web server is its only service otherwise another system could be better)

hostname www.example.com

Make apache aware of its name

In your apache-httpd configuration, (inside VirtualHosts if you use them) add this directive :

ServerName "www.example.com"

My explanation could be more plateform/distribution independent and/or more detailled, so if anyone wants to suggest additions/modifications, don't hesitate.

Share:
9,923

Related videos on Youtube

Jo E.
Author by

Jo E.

Updated on September 18, 2022

Comments

  • Jo E.
    Jo E. over 1 year

    (does the title make sense? cause I'm not sure)

    I want to host my own site. I've setup an Apache Server and I am able to call the site via IP. Now I want to call it via a domain.

    I have an extra domain from GoDaddy, normally to use those domains I change the Nameserver to the ones my Hosting is providing e.g. ns1.example.com and ns2.example.com, how do I setup the ns1.example.com and ns2.example.com on my webserver so that I can use it on my GoDaddy account?

    Sorry if this is noobish I'm new to this server stuff.

    Appreciate the help! Thanks!

    • mveroone
      mveroone over 10 years
      Do you want to be able to resolve name from your web applications, or to access you web application by it's name instead of IP ?
    • Jo E.
      Jo E. over 10 years
      @Kwaio access my web applications by its domain name instead of IP.
    • mveroone
      mveroone over 10 years
      I'm not familiar with godaddy and its interface, but what you need to do is to configure for example www.example.com to your IP address on their DNS Zone configuration page. There's nothing else to do server-side, but maybe change /etc/hosts so www.example.com resolves to your server and add ServerName www.example.comto your apache (virtualhost) configuration
    • Jo E.
      Jo E. over 10 years
      When their interface asks for the nameserver I type-in my IP(e.g. 1.1.1.1) and click ok. It then returns that what I typed-in is an invalid Nameserver and TLD error. I tried searching for that TLD error and majority of my finds say that its due to an Invalid Nameserver. Any ideas?
    • mveroone
      mveroone over 10 years
      You have to use their nameservers, and edit the Zone to add a "A" field mapping 1.1.1.1to www.example.com help.wildapricot.com/display/DOC/Godaddy+DNS+Setup+example
    • Jo E.
      Jo E. over 10 years
      @Kwaio so I point the A record from their IP to mine? And that's it? Well I can't know right now because it needs to propagate. . I'll comment when I get results. Thanks for the help!
    • user
      user over 10 years
      @Kwaio You should post that as a proper answer so you can get at least the accept :)