Step 1: Buy the Domain
I usually use Namecheap or Misk to buy the domains.
Step 2: Change the Nameservers
On Namecheap, go to your domain page, then to the Advanced DNS section, and under DNS/Host Records choose Custom for the Domain Nameserver Type. On Misk, set the nameserver entires. Then I go and enter in my custom domain name servers. I use linode, so the entries are
ns1.linode.com ns2.linode.com ns3.linode.com ns4.linode.com
Step 3: Create the DNS Entries
I manage all of my DNS on Linode. Since I’ve used the same configuration many times, I go into linode, then to the DNS manager, then scroll to the bottom and select “Clone Existing Zone.” I’ll clone a DNS configuration for an existing simple website into a new one. The main entries that are created are the mail, www, and root (or @, a blank — like website.com instead of www.website.com) to the IP of my server.
Step 4: Setup Up Name Based Virtual Host and Destination Directory
I have an apache server setup, so I need to make a new file to configure the virtual host.
// Create a folder for the new location $ cd /var/www $ mkdir mynewwebsite.com $ cd mynewwebsite.com $ touch index.html // Then you can add a test sentence there
// Go make the new file for the apache configuration // I copy an old config to a new one.
$ cd /etc/apache2/sites-available/ $ sudo cp currentsite.com mynewwebsite.com
// Then I go into vim and substitute the new name for the old name.
Using this vim command :%s/currentsite/mynewwebsite/g
1 <VirtualHost *:80> 2 3 ServerAdmin adminemail@gmail.com 4 ServerName mynewwebsite.com 5 ServerAlias www.mynewwebsite.com 6 DocumentRoot /var/www/mynewwebsite.com 7 8 <Directory /var/www/mynewwebsite.com> 9 Options Indexes FollowSymLinks 10 AllowOverride All 11 </Directory> 12 </VirtualHost>
// Enable the site so it goes into the sites-enabled directory $ sudo a2ensite mynewwebsite.com Enabling site mynewwebsite.com. Run ‘/etc/init.d/apache2 reload’ to activate new configuration!
// Then restart apache
$ sudo service apache2 restart * Restarting web server apache2 … waiting [OK].
Step 5: Test That This Works So Far
Test that this works so far by visiting your domain. You should see the contents of your index.html file. If you visited the domain too early (like I did on this tutorial), then you may have cached the landing/parking page of the DNS registrar. You can try clearing the cache using
sudo dscacheutil -flushcache
But sometimes you will just have to wait to clear the DNS cache. I also tested on my phone by visiting the page to show that the domain name → nameserver → DNS configuration → name based virtual host → index.html file all works.
Step 6: Thats it!
Visit the website to complete the configuration, but that should be it!