==========================
== Neural Market Trends ==
==========================

Installing Ghost CMS on AWS Lightsail

Blogging Tutorials

This tutorial is not about porting Hugo posts to the Ghost format but instead it’s about how I got a custom domain, CDN, and removed the :80 port from a new Ghost install.

First off, setting up the machine on AWS Lightsail is pretty easy. It was as simple as selecting the Ghost install and taking the cheapest instance possible. I think the cost is like $3.50 a month, which is pretty sweet IMHO.

The harder part was then the configuration of everything. When the instance spins up you get a dynamic IP assigned to it. It’s not a pretty custom domain name but rater something like 123.45.67.890, not easy to remember and it does change when you reboot the instance.

I had to set up a static IP (an added yearly cost) to avoid the IP from changing because I was rebooting this instance a lot.

Once I got the static IP, then I had to attached my custom domain thomasott.io to it. I thought that while I was doing that I should make sure that it’s SSL enabled and that my content would be served through a CDN (Content Delivery Network) for scalability and robustness.

Just those tasks forced me through down a rabbit hole that’s taken me about a day (on and off timewise) to configure my instance. It was fun because I got to tinker with domains, CDNs, and other backend related stuff, something I normally don’t do.

This tutorial is about how to turn your site into a real Ghost site once you go your AWS Lightsail instance running.

The Instance

I’m not going to go into detail about setting up the instance, but the four screen shots below show you how easy it is.

First click on ‘Create Instance.’

Create AWS Lightsail Instance

Then select your Instance location.

Select AWS Lightsail Instance Region

Then select Ghost.

You’ll notice there are a lot of other things you can install too. My next goal is to set up a Wordpress and Django site as a test and work through the machine configurations like this one.

Select AWS lightstail App Blueprint

Finally, you select the size of the instance you want. I went with the cheapest option.

Select AWS Lightsail Instance Plan

That’s really it, you launch it and it goes live.

Logging in to Ghost

This was an annoying part, I didn’t know where to log into the Ghost admin panel at first. The answer is:

http://YOUR-DYNAMIC-IP/ghost

But what are the credentials? The Ghost instance is managed by Bitnami and they have specific instructions on how to log into your Ghost instance. You have to SSH into the instance and run a command to get the password. The default username is bitanmi.

Once you SSH into your instance, get the password, then go to:

http://YOUR-DYNAMIC-IP/ghost

Then log in and make a new user. That user will be you and don’t forget your login credentials.

Remove Bitnami header

Once I had a user and tested logging in successfully, I then looked to get rid of that annoying Bitnami header. This was easy to do, I just used the bnhelper tool.

All I did was SSH into the instance and run sudo /opt/bitnami/bnhelper-tool

This led me to this screen and I selected Remove the Bitnami Banner.

Bitnami Configuration Screen

Done.

Set up Static IP on AWS Lightsail

My next step was to attach a static IP to the instance. That was pretty easy too, all I did was navigate to Networking and clicked on Create static IP.

Select Networking on AWS Lightsail

Then I followed the instructions but selecting where my instance was and filling out the rest of the information.

Create Static IP on AWS Lightsail

Set up Custom Domain Zone

Now this part got tricky, setting up the Custom Domain Zone. Here I wanted to attached my AWS registered domain thomasott.io to the this static IP.

In order to do that I needed to make sure that the DNS servers that this instance requires are the same DNS servers set up in my Route 53 Hosted Zone.

There are some important things you need to set up in Route 53 to make sure everything resolves correctly. The problem is that you’ll be setting them up a bit out of order.

The key things for Route 53 is this:

  1. Make sure the Domain Name Servers are the same in Route 53 and your Lightsail instance of Ghost
  2. You point an A Name record to the Cloudfront Distribution URL (we haven’t set this up yet)
  3. That your SSL certificate is verified so you can get https (we haven’t set this up yet either)

The problem is that you won’t have all the information to finish this configuration until you set up your CDN and SSL certificates.

Set up the CDN

It’s advisable to serve your images and content through a CDN (Content Delivery Network). Why? Because it helps with load times and uptime. Ever since I switched to a CDN my SEO for my other blog has skyrocketed. You should consider this too.

To set that up, just click on the Create distribution button and

Create Instance CDN on AWS Lightsail

Then follow the instructions by selecting your instance (mine is called Ghost-1).

Once you do that, you’ll get a cloudfront URL where your blog will be served too.

Important! Now you’ll have to navigate back to Route 53. In your Hosted Zone for your custom domain, create an ‘A’ Record but select Alias to Cloudfront distribution.

Route Web Traffice to Instance CDN on AWS Lightsail

If you select the correct Instance location, your newly created Cloudfront distribution should populate automatically.

Done!

Set SSL Certificates on AWS Lightsail

We’re still not done yet with setting up the custom domain. For that you’ll need to attach SSL certificates and then reference them back in Route 53.

Click on the Distribution button and navigate down to the enable custom domain option.

Create Custom Domain on AWS Lightsail

Select enable.

Then navigate lower on the page and click Create certificate. Fill in your apex domain name (not www.your-custom-domain.com, but custom-domain.com).

Create SSL Certificates on AWS Lightsail

Once you create your SSL certificate, it will ask you to verify it. You will need to take that information and create a CNAME record in Route 53. Once you do that, you should be done with all your Custom Domain Name/Zone configurations.

The remaining steps are related to the backend of Ghost and configuration the web and production server.

Update Machine Name

SSH into your instance and update your machine name. To do that you’ll need to do the following commands referenced here.

sudo /opt/bitnami/apps/ghost/bnconfig --machine_hostname example.com

where you replace example.com with your custom domain.

Then to make sure it ‘sticks’ when reboot you’ll have to rename the bnconfg file like so:

sudo mv /opt/bitnami/apps/ghost/bnconfig /opt/bitnami/apps/ghost/bnconfig.disabled

Update httpd-vhost.conf

This next step caused me grief because I couldn’t find the damn httpd-vhost.conf file at first.

I finally found it at /opt/bitnami/apps/ghost/conf/

You have to edit this file and update it with your custom domain information. I followed ‘Approach B’ in these instructions.

Then I restarted the web server.

Update Production settings

Once I got this point everything started to work well except I had the port :80 appended to my custom domain thomasott.io. it drove me nuts.

It wasn’t until I read this post on how to remove it that I realized there’s this production setting for Ghost.

One I removed the :80 from the JSON file and restarted the instance, everything work.

End notes

I’m probably forgetting something because these were small tweaks were numerous but not hard. I will update this post with any missing information when I remember it.

Learning Python Programming the Easy Way


I picked up python programming when I needed to do something but couldn't figure out how to connect the dots. Luckily there were some great books out there that I picked up and helped accelerate my learning process.

Here is a list of book and cheatsheets I like:

comments powered by Disqus