first things first


A blog about whatever crosses my mind, ordered by importance.


hosting the blog

I decided to use Amazon EC2 to host the blog, because they give you 1 year free on a micro instance. Plus I’ve always wanted to learn how to host something on Amazon’s cloud. I’ll get a linux instance and put an Apache HTTP server on it. Should be easy enough to do.

Here’s my EC2 management console after signing up for an Amazon account and creating a linux micro instance: ![EC2 Management console](/images/2014/EC2 management console.png)

It took a bit to then be able to log in. I had to add a security group that allowed SSH login, then used my ssh key generated by Amazon to ssh into the instance. It gave me an error, ‘permissions are too open’, so I had to change the key permissions to only be readable by my user: chmod 400 ~/.ssh/macbook.pem. ![SSH login to instance](/images/2014/ssh login to ec2.png)

Adding Apache HTTP turned out to be easier than I thought. The linux AMI comes preinstalled with Yum, which is a linux package manager. I just had to yum install httpd, then start up the service. I followed this tutorial: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html

The main gotcha was I hadn’t yet added a security group to allow HTTP traffic to my instance. That was fairly easy and fortunately the tutorial pointed it out. I admit I don’t understand all the linux-ese but the tutorial fortunately explained what was going on.

I had to change the hostname and regenerate the site. I suppose I’ll try to modify the theme so that it’s less dependent on the hostname, but I think it will be easier to just codify that into a deploy script. Generating the site looked like this:

hugo --baseUrl="http://ec2-54-149-156-115.us-west-2.compute.amazonaws.com" --theme=hugo-uno

I then copied the files from the ‘public’ folder to /var/www/html on the server using scp. Here’s the command:

scp -i ~/.ssh/macbook.pem -r ./ ec2-user@ec2-54-149-156-115.us-west-2.compute.amazonaws.com:/var/www/html

After that I could navigate to http://ec2-54-149-156-115.us-west-2.compute.amazonaws.com/ in my browser and my blog worked! Hooray!

I’ll probably code all that up into a deploy script eventually.

The final step was hooking it up to my domain. I allocated an elastic IP for my amazon instance, and updated my 1and1 domain’s A record to point to it. Then I just had to rebuild the site for my domain and push it. hugo --baseUrl="gordonburgett.net" --theme=hugo-uno