Website Hosting with Custom Domain Name

From Earlham CS Department
Revision as of 11:39, 16 November 2018 by Craigje (talk | contribs)
Jump to navigation Jump to search

We were asked to host a site for a student group, and it happens they had a domain they wanted to use. Forwarding wasn't enough: they wanted the site to not appear as if originating from This is the guide.

Note: This guide will be updated when we resolve some issues with SSL.


We assume you're running this on CS, which uses Apache as the web server. The instructions will be different in places running nginx. This also assumes familiarity with the terminal, bind/DNS, and basic networking.

Also, have the following information at the ready:

  • the IP address of your web host - as an example, we'll use, as per the rules
  • the domain name - we'll use

Domain: Replace the DNS records.

You'll need to replace the DNS records - which indicate which IP address your domain should point to - with your own.

First delete the old hosts. (If you need to backtrack, it's usually not hard to reset to the default hosts later.)

Add two A records:

  • hostname @,
  • hostname www,

I used Hover's default 15 minute TTL, but (as we millennials say) you do you.

No need to worry about the name servers.

Add to /etc/hosts

Add a line to /etc/hosts reading as follows:

Or append to the existing line for your IP address.

Add to Bind

In /etc/bind/, add the CNAME:

example      IN     CNAME

Run service bind9 restart or your OS-specific service manager to update the bind configs.

Create a VirtualHost on Apache

In your available sites path, in our case /etc/apache2/sites-available, copy the default (000-default.conf) file to a new file for your site:

cp 000-default.conf

Edit as follows:

DocumentRoot "/path/to/your/content/or/cms"

The DocumentRoot portion is where you might point to, say, a WordPress directory or a group of publicly-accessible user files. The nice thing about this is that it's somewhat modular: these steps apply to CMS systems in general, not just WordPress as in our use case.

If you want, you can also do specific configuration edits here - for example, I put the error log in a separate directory when testing this.

Run a2ensite to activate a site with the configuration you've provided.

Run service apache2 reload or your OS-specific service manager to refresh the Apache settings.


service apache2 reload

Verify or Fix


If it didn't work, retrace your steps carefully. Check for typos, skipped steps, etc.

A note about iterative development and DNS

To grossly oversimplify, a lot of programming involves fast iterations: make some change, check if it worked, if so great, else repeat with a new change. DNS frustrates that workflow because you have to wait for DNS changes to propagate. If you're getting inexplicable results at some point, propagation is probably the reason. Give it time. If a long wait is bugging you, check the URL on a different computer than your usual workstation.