Pointing DNS to Your Web Server with EntryDNS

This guide is intended for people who are hosting a site with a cloud-based server or a server with a public IP address. Folks who are hosting a site on a home computer with a home internet connection with a dynamic IP address need to use a dynamic DNS service. Namecheap is probably the best registrar to go to for this scenario, and here is a guide on how to set that up.

So you’ve decided to do your own web hosting and set up your own web server. You may have followed this guide on setting up a free/cheap virtual wordpress server on Amazon Web Services and liked the result. Now you want a pretty domain name to match your pretty wordpress hyperlinks.

Lets face it, http://54.XX.XX.XX/blog, just does not have that great of a ring to it.

dns-i

You can get the rest of the way towards having “yourname.com” up and running in a few cheap and/or free steps. That is assuming your name is super unique. Trust me, if its not, its already registered.

There have been a million guides to registering your own domain name, basically you are going to have to pay between $5 and $10 per year at the registrar of your choice and follow their steps towards signing up and registering an available address. Coupole that with as low as $35 a year for your AWS micro instance and you’re looking at around $4 a month for a good looking website/blog. Here is a good article of the top 5 registrars. 

Many or most of these also offer hosting plans, and you are free to use them but if you want complete control of your site, you have your own web server and it’s either cloud-based on something like AWS or its a real or virtual server and you’ve got your port 80 traffic going to it from your Public IP address.

The way to link these two things together is with DNS management services, which your registrar may or may not offer for free. If they do not offer free DNS management.

AWS itself offers cheap DNS management through it’s Route 53 console. However there is a long way between cheap and free and I like free.

Head over to entry DNS and sign up for a free account.

Then click the “Add Domain Button”

Screen shot 2013-12-20 at 9.35.38 AM

and you will enter your registered domain name, IP address of your server and take note of the name servers listed on the page, in this case

ns1.entrydns.net

Screen shot 2013-12-20 at 9.36.13 AM

Now just head back over to your registrar and enter this nameserver in the DNS settings and when people type in your domain it will point straight to your webserver and no longer show the ugly IP address in the address bar.

Here are guides for using your own name server with the registrars listed: 1 and 1, Namecheap, GoDaddy,

Launch a simple WordPress site using Amazon Web Services

Who doesn’t love WordPress? It is responsible for somewhere around 19% of the web’s content and if you’ve never used it you should give it a try. Who doesn’t want to learn how to use AWS? Well probably most people but I’ve been liking the granular control of AWS since I started playing around with it. If you want to give it a spin, here is a brief tutorial that should get you up and running in about a half hour and give you a look at many of the key components.

First of all you are going to need to set yourself up, depending upon your OS and what you already have going on, you are going to need to install an SSH client, Putty is a great free tool and the software of choice for most, but I actually like the free edition of MobaXTerm as it automatically supports the .pem public key format from amazon, is more colorful and has SFTP built right in.


Screen shot 2013-12-18 at 9.15.46 AM

You will be using the terminal, SSH and the Linux command line for this project.

Next head over to AWS.amazon.com and sign up for a free tier account. This will allow you to use up to 750 hours of hosting for free among other things.

Once you have done all the verification steps and are able to log into the AWS console head to the EC2 Managment Console

Screen shot 2013-12-18 at 9.39.52 AM

 

In the Network and Security section make a new keypair and download the .pem file to your computer and put it in a safe location. This is the public key encryption information that take the place of a password for your server. It is more secure tan a simple password as long as you keep the file away from prying eyes. In fact on Linux and OSX you will need to chang the permissions of the .pem file to 600 (Only You can Read and Write all others forbidden) in order to use it to connect. You can do this simply on the command line using: 

sudo chmod 600 /pathtoyourfile/keyname.pem

Now you can use your terminal program of choice to connect to your server isntance once you create it in AWS.

Now you can go ahead and head back to the root of the AWS console by clicking the orange box in the upper left. Now head over to Cloud Formation.

Screen shot 2013-12-18 at 9.48.59 AM

This is where you can set up templates for server instances that you can create on demand. Click the “Create Stack” button to begin the process you can tinker with custom test based templates to your heart’s content in the future, but for now give your template a name like “WordPressLab” and use the following URL in the “Provide a Template URL field”

https://s3.amazonaws.com/cloudformation-templates-us-east-1/WordPress_Single_Instance.template

Screen shot 2013-12-18 at 9.50.38 AM

In the next screen enter strong passwords. You’ll need to enter your key name that you chose and CHANGE THE INSTANCE type to:

t1.micro

If you do not enter the key exactly you will not be able to connect and if you do not change the instance type it won’t be free. If you have a static ip address for your home computer or dont mind changing this seting frequently for added security change the SSH Address to 111.111.111.111/32 where the 1’s are your systems static IP address, that way only that system can log in through SSH with the encrypted key.

Skip by the “Tags” screen and you should get to the confirmation screen.

Screen shot 2013-12-18 at 10.00.51 AM

and clear the next screen and you should see this in the Cloud Formation console:

Screen shot 2013-12-18 at 10.03.43 AM

 

Head back on over to the EC2 Instance Manager where you made the Key Pair and take a 5 minute coffee break.

You should now have a running WordPress Web Server and the console will look somewhat like this:

Screen shot 2013-12-18 at 10.11.58 AM copy

 

The IP address listed there is a public IP and you can put it in a new browser window and you will see that your Apache is up and running just fine.

If you head to http://yourserverIP/wordpress/ the wizard will let you create a login to your new blog. Its easy as pie from there.

Screen shot 2013-12-18 at 10.07.54 AM

 

Screen shot 2013-12-18 at 10.08.06 AM Screen shot 2013-12-18 at 10.09.54 AM

However, you are not done that easily. Unfortunately your server does not support pretty hyperlinks so your blog posts will always have ugly names and you really don’t want that. Also you should know how to login to your server via SSH so fire up your terminal program.

If you are using ModXterm you simply need to set up an new connection and chose the .pem key in the connection screen, the username is

ec2-user

Its similar using putty but you need to use putty convert to to change the pem file to a ptk file, just google that. This is not a Putty or ModXterm article.

If you are using a linux or OSX terminal use:

ssh ec2-user@yourserverip -i /pathtopemfile/keyname.pem

Add the server with a yes and you are greeted with:

:~ user$ ssh ec2-user@yourserverip -i /pathtokey/keyname.pem
The authenticity of host 'yourserverip' can't be established.
RSA key fingerprint is a5:44:98:e9:88:c9:ea:ec:24:26:eb:a2:fb:13:ce:46.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'your server ip' (RSA) to the list of known hosts.
__| __|_ )
 _| ( / Amazon Linux AMI
 ___|\___|___|
See /usr/share/doc/system-release/ for latest release notes.
There are 38 security update(s) out of 243 total update(s) available
Amazon Linux version 2013.09 is available.
[ec2-user@ip-172-31-7-36 ~]$

Now you are in, you can use the SUDO command to do root things and have control to your heart’s content. In order to enable the pretty hyperlinks you ned to issue the following command, this is assuming you know how to use the vi editor:

sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup
sudo vi /etc/httpd/conf/httpd.conf

Find the section here:

 

Screen shot 2013-12-18 at 10.28.23 AM

 

And change BOTH instances of:

AllowOverride None

to

AllowOverride All

Save your file and then use

sudo httpd -k restart

Now you are ready to log back into your wordpress blog, head to settings>permalinks and choose the permalink you you want. You are also ready to SSH in when you need to!

Happy Pressing!