Setup a domain name for a new website or server.

Dave O'Dea
· 4 min read

This is part 4 in “How to set up your own cloud based web server

  1. Create a server.

2. Setup the server.

3. Install the LAMP stack.

4. Setup a domain name (i.e. ← You are here !

5. Getting files on the server.

At this point we are nearly finished this series. So far, we have learned how to create a server , setup the server and install the LAMP stack .

We now have a website that responds to our public IP for the server.
However, what we need to do is connect a domain name i.e. to our server via DNS settings on DigitalOcean’s dashboard.

Lets get stuck in …

  1. Purchase a domain:

I won’t spend too long on this step as the process is fairly straight forward when using any of the big name providers. I like to use simply because they are cheap and it straight forward to edit the DNS setting which we will need to do for the next step.
Once you have purchased your domain, log into your GoDaddy account go to the section “Manage my domains”.

2. Change DNS nameservers:

Currently, our domain is being managed by GoDaddy’s name servers.
DNS name servers simply work like this (at a high level):

  • You enter a URL in your browser →
  • The URL gets routed to the name server responsible for said URL →
  • The name server looks up its own tables to see “… hey, who owns this URL/domain” →
  • It then directs your browser to the relevant server IP attached to that domain.

So, with that in mind, lets change the name servers to DigitalOcean’s as this is where our server is located:

Now, select the dropdown menu beside your listed domain:

Go to ‘ Set Nameservers ’ :

Click to edit the name servers and set them as:


Make sure to save.

3. Setup domain on DigitalOcean:

At this point we will head over to your DO dashboard and go to the networking section:

Enter in your new domain name and click ‘ Add domain ’ .

Next we will enter the relevant records for your domain.

The most important for now being A records. These type of records allows us to point the IP of our server at our domain, and because DO is looking after our DNS name serving, our server will be what is returned to the user.

In the HOSTNAME section, enter ‘ @ ’ . This means that whatever is entered before your domain, for example:

… will be directed to your site.

In the WILL DIRECT TO section, select your droplet from the list. You may leave TTL at its default value , hit ‘ Create Record ’.

In order to set a wildcard for any subdomain entered before your domain i.e.

  • you get the idea …

… we need to set a CNAME record as follows:

That is all we need for now — if you do need to add mail DNS records, for example Gmail — you can select MX and DigitalOcean actually has an automatic importer that you can use to set these:

Once you are done, they records can take up to 24 hours to take effect, but in reality I have always only had to wait a few minutes.

We can test that we did everything correct by firing up our terminal, on our local machine, and pinging our domain:


or a sub-domain:


… you should get something back like:

… not to mention, you should also be able to enter the the domain into your browser — awesome work !

Next up, let’s figure out how to get the files transferred from our local machine and up onto our server so we can display our website in all its glory !

Lets do this …

Kitchen to Keyboard

One fella’s journey from Professional Chef to Software Engineer

Dave O'Dea

Written by


Kitchen to Keyboard

One fella’s journey from Professional Chef to Software Engineer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade