Installing Ghost 1.0 on a Lightsail or EC2 instance

July 12, 2017 0 Comments

By request, this post details how to install the Ghost blog engine (version 1.0, which is currently in Beta), on an AWS Lightsail or EC2 instance.

Prepare your instance - Lightsail

  • Open the Lightsail console at
  • Click 'Create instance'.
  • Choose your preferred region.
  • Choose 'OS only' and 'Ubuntu'.
  • Change the SSH key pair, either selecting one you have in your account already or downloading a new one (a .pem file you'll use later).
  • Accept the default instance size.
  • Give your instance a sensible name (note: you can't change this later!). Create!
  • If you want to make your life easier later should you change the instance, you can click 'create Static IP', select your new instance and give your IP a sensible name (you can't change this later either).

Prepare your instance - EC2

  • Open the EC2 console at - ensure your preferred region is selected in the drop-down at the top right.
  • Click 'Launch instance'.
  • Select the 'Ubuntu Server 16.04 LTS' AMI.
  • Choose an appropriate instance type (use t2.micro for the free tier).
  • Click 'Review and Launch'.
  • Click 'Launch' - you will be prompted to select the SSH key pair, either select one you have in your account already or download a new one (a .pem file you'll use later). Launch!
  • If you want to make your life easier later should you change the instance, you can assign it an 'Elastic IP'. In the EC2 dashboard, Select 'Elastic IPs', 'Allocate new address' then 'Allocate'. When the new IP appears in the list, check the box next to it, choose 'Associate address' from the 'Actions' menu and choose your new instance.
  • Your new instance will be assigned a Security Group. You should ensure this allows access on port 80 and 443 as well as port 22 (SSH).

Configure you instance and install Ghost - Both types

  • Now that you have your instance IP or your static / elastic IP, you can set up your DNS. This will make it easier to connect to your instance by name. You can use route53 at AWS for this, but I highly recommend the excellent CloudFlare. It makes sense to do this now, as the Ghost installer will prompt you for a URL for your blog. If you are using Cloudflare, I recommend enabling Strict SSL so the connection between CloudFlare and your blog is encrypted.
  • Connect to your new server via SSH, using the command line (Linux / Bash for Windows) or a tool such as Putty. You'll need to use the pem file you downloaded and the username 'ubuntu' (e.g. 'ssh -i downloadedkey.pem [email protected]').
  • If you are running on a server with less than 1GB RAM (e.g. the base Lightsail offering - the free tier EC2 instance should be fine), then you should set up some swap space at this point, as the install can use a fair bit of RAM. Use the following commands - 'sudo fallocate -l 2G /swapfile', then 'sudo chmod 600 /swapfile', then 'sudo mkswap /swapfile', then 'sudo swapon /swapfile'. Done. You shouldn't need to add this to fstab, as it's only the install process that needs the extra RAM. After the next reboot (or after install, having run 'sudo swapoff -a'), you can remove the swapfile ('sudo rm /swapfile').
  • Update the package list - 'sudo apt update'.
  • Install any waiting updates - 'sudo apt upgrade -y' - accept the defaults on any prompts.
  • Enable automatic security updates - 'sudo dpkg-reconfigure --priority=low unattended-upgrades' - accept the defaults when prompted.
  • Install Nginx (the web server) - 'sudo apt install -y nginx'.
  • Install MySQL (the database server) - 'sudo apt install -y mysql-server' - you'll be prompted for a new MySQL root password, remember this as you'll need it later!
  • Install NodeJS (the scripting language) - 'curl -sL | sudo -E bash -' then 'sudo apt-get install -y nodejs'.
  • Install Ghost-CLI (the tool used to manage Ghost) - 'sudo npm i -g ghost-cli'.
  • Create a folder for your Ghost install - 'sudo mkdir /var/www/ghost'.
  • Set the directory ownership to your user - 'sudo chown ubuntu:ubuntu /var/www/ghost'.
  • Navigate to the new directory - 'cd /var/www/ghost'.
  • Install Ghost! - 'ghost install'. The prompts will be as follows:
  • 'Enter your blog URL' - this should be set to the https address of your DNS entry - e.g. ''.
  • 'Enter your MySQL hostname' - press enter to accept the default.
  • 'Enter your MySQL username' - this will be 'root'.
  • 'Enter your MySQL password' - this will be the password you chose earlier.
  • 'Enter your Ghost database name' - press enter to accept the default.
  • Answer 'Y' to 'Do you wish to set up a ghost mysql user?'.
  • Answer 'Y' to 'Do you wish to set up a ghost system user?'.
  • Answer 'Y' to 'Do you wish to set up nginx?'.
  • Answer 'Y' to 'Ghost-CLI would like to generate a nginx config file.'
  • Answer 'Y' to 'Do you wish to set up ssl?'.
  • Enter your email address. This is for the LetsEncrypt free SSL service notifications.
  • Answer 'Y' to 'Ghost-CLI would like to generate a ssl parameters file'.
  • Answer 'Y' to 'Do you wish to set up automatic ssl renewal?'.
  • Answer 'Y' to 'Do you wish to set up systemd?'.
  • Answer 'Y' to 'Ghost-CLI would like to generate a systemd service file'.
  • Answer 'Y' to 'Do you want to start Ghost?'.
  • Answer 'Y' to 'Do you wish to enable the Ghost instance to start on reboot?'.
  • That's it, you should now be able to access your blog on the provided URL! Append '/admin' to set up the admin account etc. If for any reason you break out of the process above, you will need to clear out the directory to do it again ('sudo rm -r && rm .*').
Paul O'Brien
Paul O'Brien
Norwich, Norfolk
IT Director, founder, dad, writer, snowboarder, gooner, mobile / cloud / Linux expert. Striving to bridge the gap between tech & humans.

You've successfully subscribed to paulobrien's blog
Great! Next, complete checkout for full access to paulobrien's blog
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.